How to use clearInterval() in Angular 4
You can set like this,
this.interval = setInterval(() => {
}, 1000);
and clear like this,
if (this.interval) {
clearInterval(this.interval);
}
If you want in same method with some condition
var a = 1;
this.interval = setInterval(() => {
console.log(a++)
if(a > 30){
clearInterval(this.interval);
}
}, 1000);