How to clear or stop timeInterval in angularjs?

后端 未结 5 1917
不知归路
不知归路 2020-11-30 19:09

I am making a demo in which I am fetching data from the server after regular intervals of time using $interval Now I need to stop/cancel this.

How I can

5条回答
  •  情歌与酒
    2020-11-30 20:08

    var interval = $interval(function() {
      console.log('say hello');
    }, 1000);
    
    $interval.cancel(interval);
    

提交回复
热议问题