I use $timeout to regularly update information on one of the pages in my angularjs application. I would like to cancel $timeout when the user navigates from this page. Is there an easy way to do this?
$timeout
Ok, I found a solution after digging:
$scope.$on('$destroy', function() { $timeout.cancel(timeout); });
Or for the new component syntax in Angular 1.5:
this.$onDestroy = function() { if (timeout) { $timeout.cancel(timeout); } }
Source: https://habr.com/ru/post/948870/More articles:Scalding: How to save another field after groupBy (') {. Size}? - twitterAny reason not to use Redis 32bit (as opposed to 64-bit), with the exception of the 4 GB limit? - ubuntuScalping, smoothing fields after groupBy - scalaClojure operator → (arrow) and additional operations - clojureDifferences between def up and def change in a migration file - databaseIs it safe to access a variable from the main stream after it has been recorded by another stream and after this stream has been attached? - c ++R to return the package license? - rparameterized queries against SQL injection - c #C # How to completely remove an object from memory - c #How to switch sql worksheet display in oracle sql developer 3.2 - oracleAll Articles