How can I stop an AngularJS $interval? -


i have code inside function gets called every 1 or 2 minutes. counts down 60 0 (i've set 60 maximum number of iterations).

var timer = $interval(    function (times: number) {       var retry = 60 - times;       $scope.retrymessage = "retry + " seconds";    }, 1000, 60); 

from can see documentation suggesting $interval must cancelled when can this? assume cannot add:

$interval.cancel(timer); 

after code.

$interval returns promise. can cancel this

var times = 60; var promise = $interval(    function () {       var retry = 60 - (times++);       $scope.retrymessage = retry + " seconds";       if(retry == 30){ //cancel in 30 seconds instead .. reason           $interval.cancel(promise);       }    }, 1000, 60); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -