Wednesday, 15 April 2015

javascript - Cancel a AngularJS $timeout on routeChange -



javascript - Cancel a AngularJS $timeout on routeChange -

on specific page in application think of doing server-call update info on set interval. stumbled upon problem though. want cancel $timeout when user navigates away page in question application doesn't seek work stuff isn't there anymore.

any ideas on how work around this?

use $timeout.cancel this:

yourtimer = $timeout(function() { /* ... */ }, 5000); $timeout.cancel(yourtimer);

reference

javascript timeout angularjs

No comments:

Post a Comment