Tommy
Member since Aug 24, 2014
- Profile: /members/12225-tommy.htm
- URL: http://www.comeet.co
- Comments: 3
Recent Blog Comments By Tommy
-
Don't Forget To Cancel $timeout Timers In Your $destroy Events In AngularJS
Posted on Oct 12, 2015 at 4:38 AM
Thanks @Guy, That's brilliant!... read more »
-
Don't Forget To Cancel $timeout Timers In Your $destroy Events In AngularJS
Posted on Sep 29, 2014 at 3:24 PM
Thanks for the thoughtful response. Since this is so common, I would make it a practice to have all the timers in an array like $scope.timeouts. Then have a generic util function that will get the scope, and will subscribe to the $destroy event to then cancel all timers. Thanks again!... read more »
-
Don't Forget To Cancel $timeout Timers In Your $destroy Events In AngularJS
Posted on Aug 24, 2014 at 12:59 PM
I wonder how it may be possible to skip subscribing to each $destroy event to cancel each $timeout. Maybe if you place the $timeout instance in a property inside the scope object, itwould be cancelled as the outcome of the scope being destroyed. instead of: var timer = $timeout(someHandler); do: ... read more »