To cleanup the timeout, just use ".cancel()":
var customTimeout = $timeout(function () {
// your code
}, 55);
$timeout.cancel(customTimeout);
The same applies to $interval().
To disable a watch, just call it.
// .$watch() returns a deregistration function that we store to a variable
var deregisterWatchFn = $rootScope.$watch(anyGloballyAvailableProperty, function (newValue) {
if (newValue) {
// we invoke that deregistration function, to disable the watch
deregisterWatchFn();
//your code
}
});
0 Comment(s)