My ngOndestroy calls another route navigation, but does not execute clearInterval inside the method. Where am I doing this wrong? It works in the background, and I in another component.
timer:any; ngOnInit() { this.timer= this.interval(); }; ngOnDestroy(){ clearInterval(this.timer); console.log("Inside Destroy"); } interval(){ setInterval(()=>{ this.getData(); },20000) } getData(){ this.dataservice.getdata() .subscribe(users=>{ this.datas=users; console.log(this.datas); }) }
source share