Reputation: 32758
I have the following:
$scope.$watch('city', function (newValue, oldValue) {
But I want to stop the watch when I populate a new city list. How can I remove the watch ?
Upvotes: 0
Views: 214
Reputation: 467
$watch returns a function to remove the added event listener.
So you must save the returned function from your watch execution to later disable the watch via the returned function.
Here is an example:
var myWatchFn = $scope.$watch('myVariable', myWatcher);
// Remove watch.
myWatchFn();
Upvotes: 8