I am trying to use setInterval in my Angular 4 app.
const inter = setInterval(() => {
// logic resulting in exitCondition
if(exitCondition) {
clearInterval(inter);
}
}, 1000);
This set up works fine in vanilla javascript, but clearInterval()
does not seem to work in Angular. Upon doing some research I found an interval service for Angular 1.x :
https://docs.angularjs.org/api/ng/service/$interval
Is there anything similar for Angular 4? Or is there a workaround to make clearInterval() work?