I’m using tabs on ionic 2 with typescript.
I have a timer on tab 1 that checks the db every second.
On tab 2, I have a timer that does the same
I don’t want the timer script on tab one to run if and when the user is on tab 2.
I’ve tried using the tab id
this.tab_id = nav.id
if(this.tab_id==‘0-0’ && this.tab_id!=‘0-1’){
this.start()
setInterval(()=>{
this.start()
},2000)
}
this doesn’t work… the script in tab one keeps running after clicking tab 2
I also tried this on tab1.ts
ionViewDidEnter() {
this.start()
this.run_scripts = setInterval(()=>{
this.start()
},2000)
}
ionViewDidLeave() {
clearInterval(this.run_scripts);
}
Any idea’s how I can accomplish this?