0

I need to change the interval value based on user inputs as following:

scope.refreshEvery = 1000;

//run on startup every 1 second
scope.interval = $interval(function () {
    scope.refresh(scope.page);
}.bind(this), refreshEvery);

//onclick will change the interval to 2 seconds 
scope.onclick = function () {
    scope.refreshEvery = 2000;
}

I have seen few solutions for JS setTimeout with recursive but that will not work here specially from a performance aspect as its recommended to cancel all the timeout and interval with the scope destroying event. Is this possible with angular $interval!

Joy
  • 9,430
  • 11
  • 44
  • 95
Amgad Fahmi
  • 4,349
  • 3
  • 19
  • 18

0 Answers0