Friday, December 25, 2015

AngularJS Cancel $timeout

$timeout returns a promise. This promise is resolved when delay is passed and the timeout function is executed.

To cancel the timeout request, call $timeout.cancel(promise).

Here is an example on how to cancel the $timeout

//setting timeout and storing the return value in a local variable
var promise = $timeout(function () {
    //code to be executed after 50 milliseconds
}, 50);

//Cancelling the above timeout by passing the promise



  1. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
    Python Training in Chennai|Angularjs training in chennai