Issue
I can set up a $watch on an AngularJS scope to be notified when the expression I am interested in has changed. But how do I stop watching once I lose interest?
Solution
When calling $watch a function is returned that unregisters the bound expression.
E.g., to watch a variable foo only change once:
var unregister = $scope.$watch('foo', function () {
// Do something interesting here ...
unregister();
});
Hope that helps :-)
Answered By - Golo Roden
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.