One view one controller running

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 =

if(this.tab_id==‘0-0’ && this.tab_id!=‘0-1’){
this doesn’t work… the script in tab one keeps running after clicking tab 2

I also tried this on tab1.ts

ionViewDidEnter() {
this.run_scripts = setInterval(()=>{
ionViewDidLeave() {
Any idea’s how I can accomplish this?

So in general I think you’re looking for an implementation to “isolate”, I think the following might work out


  “selector”: "MyTabComponent1"
export class MyTabComponent1 {
  ngViewInit() {
    // start your timer
  ngOnDestroy() {
    // unset your timer

Do the same for tab content component 2, use ion* hooks instead of ng* hooks if you can ionViewLoaded, ionViewWillLeave.