I have a watch function in my AngularJS application.
$scope.$watch('quartzCrystal', function () {
...
}
However, after some condition (in my example, changing the page at my single-page application) I want to stop that watch (as like clearing timeout).
How can I do that?
$watch
returns a deregistration function. Calling it would deregister the $watcher
.
var listener = $scope.$watch("quartz", function () {});
// ...
listener(); // Would clear the watch