Watching the value of function in an AngularJS directive
Try placing the watch on 'editable()'
instead of 'editable'
Explanation: The reason this is needed is because '&'
points to a dynamically generated function wrapper for the attribute expression rather than the expression itself. This special wrapper function returns the value of account.hasRole('ROLE_ADMIN')
.
i would also prefer doing something like that:
scope.$watch(function () {
return scope.editable();
}, function (val) {
// ...
});