As you know $watch registers a listener callback that is
executed whenever the watch expression changes.
The $watch function returns a deregister function. Calling
this deregister function will deregister the $watch expression
Here is an example on registering and deregistering the
$watch expression
//registering the $watch listener. It
returns a deregister function
var deregister = $scope.$watch('name', function(newValue, oldValue) {
//code here
});
//calling the deregister function
deregister();
No comments:
Post a Comment