I\'m trying to figure out why I\'m having trouble overwriting a value passed to an angularJS directive via an isolate scope (@). I try to overwrite the value o
Apparently it has something to do with one-way binding of the scope index value. So Angular won't update scope.index (or this.index in case of bindToController: true) because scope is configured as
scope: {
index: '@'
},
If you change it to two-way binding like:
scope: {
index: '='
},
It will work:
Demo: http://plnkr.co/edit/kq16cpk7gyw8IE7HiaQL?p=preview
UPD. @pankajparkar made a good point that updating value in the next digest fixed the issue. This approach for the problem then is closer then what I did in this answer.