Passing object from parent controller to isolated scope child directive

Viewed 5771

I have an object that I want watched inside a directive.
The directive has isolated scope and the object comes from a parent controller.

DOM:
<div hello-directive obj-to-track="{{myObj}}"></div>

Directive JS:

scope:{
   objToTrack:'@'
},
link:function(scope,element,attrs){
   scope.$watch(function(newValue){
      //Inside here, newValue is a JSON string
      //So is scope.objToTrack
   });
}

Is there anyway to get an actual object from the parent controller besides JSON.parse()
Thanks.

1 Answers
Related