Reputation: 915
I'm trying to pass a model (Object) into the scope of the directive but it is passing a string instead of the object.
The directive html.
<blabla obj="obj"></blabla>
Directive:
.directive( 'blabla' , function(){
return {
restrict : 'E',
replace: 'true',
scope :{
obj : '=obj'
},
link : function(scope , elem , attrs){ console.log(attrs);
scope.obj = attrs.obj;
}
}})
Then in the controller I have:
$scope.obj = { name : "obj"};
And this is what I get in the console
obj: "obj"
Am I missing something? Why is it rendering 'obj' as a String instead of fetching the object? If I print the object on the page it works, but it doesn't work to pass it into the directive.
Upvotes: 0
Views: 61
Reputation: 10298
Don't use attrs.obj. You should already have obj on the scope once the link function is run
Upvotes: 3