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 s
$parse will solve your problem.
app.directive('ngUpdate1', function($parse) {
return function(scope, element, attrs) {
var model = $parse(attrs.ngUpdate1);
console.log(model(scope)); // logs "test"
element.bind('click', function() {
model.assign(scope, "Button 1");
scope.$apply();
});
};
});
Fiddle
Whenever a directive does not use an isolate scope and you specify a scope property using an attribute, and you want to modify the value, use $parse.
If you don't need to modify the value, you can use $eval instead:
console.log(scope.$eval(attrs.ngUpdate1));