I wonder is it possible to execute some callback only once after evaluation all (or only some) attributes of directive (without isolated scope). Attributes are really great to p
You can use $watch
to evaluate a custom function rather than a specific model.
i.e.
$scope.$watch(function () {
return [$attrs.name, $attrs.surname];
}, action, true);
That will be run on all $digest
cycles, and if $watch
detects the return array (or however you want to structure your function's return value) doesn't match the old value, the callback argument to $watch
will fire. If you do use an object as the return value though, make sure to leave the true
value in for the last argument to $watch
so that $watch
will do a deep compare.