I have have a directive inside an ng-repeater that should set a scope property.
Please see the fiddle here: http://jsfiddle.net/paos/CSbRB/
The problem is that the scope property is given as an attribute value like this:
<button ng-update1=inputdata.title>click me</button>
The directive is supposed to set the scope property inputdata.title to some string. This does not work:
app.directive('ngUpdate1', function() {
return function(scope, element, attrs) {
element.bind('click', function() {
scope.$apply(function() {
scope[ attrs.ngUpdate1 ] = Button 1;
});
});
};
});
However, assigning directly works:
scope[inputdata][title] = Button 1;
Can you please tell me how I can set a scope property with . notation in its name from a directive?
PS: The reason the fiddle is using a repeater is because it makes the directives be in child scopes. When they are in a child scope, you can't write to scope properties that are primitives. That's why I need an object property with . in the name. See the long explanation here: What are the nuances of scope prototypal / prototypical inheritance in AngularJS?
Thank you