How to disable Watcher in AngularJS?

$watch returns a de-registration function. Calling it would de-register the $watcher.

var myVariableWatchObj = $scope.$watch("myWatchAttribute", function () {
          // code to perform
});
//.. Calling function as below would clear the watch
myVariableWatchObj();

Join Discussion

This site uses Akismet to reduce spam. Learn how your comment data is processed.