I am passing a string to my isolated directive with the @ scope configuration, hoping to be able to get that string as an object on the scope, which could then be assigned a value.
HTML
<div directive model="object.property.property"></div>
JS
directive('directive', function($parse) {
scope: {
model: '@'
},
link: function (scope, elem, attrs) {
var object = $parse(scope.model);
object(scope);
scope.object.property.property = 'newstring';
// scope.object.property.property = 'newstring';
}
});
I was hoping that this would allow me to get object.property.property onto the scope with a value of newstring.
It doesn't seem that I am using the $parse service correctly, but most of the examples I am finding are related to using $parse to convert JSON. How can I use parse to turn this string into an object on the directive's scope?
Thanks!
@is to do text binding, not object binding. why can't you use the=in the scope?<div directive model="{{objectFromParent}}.propertyDeclaredHere">