Ionic Tabs - Controller of first tab component firing twice


#1

Hello guys.

I have a component which has tabs. The default tab’s controller sometimes fires twice, depending from where it is called.

The way i’m calling it is by:
this.navCtrl.push(TabsPage, id: id});

I get the same problem either on Android device or on browser testing.

Anyone else has this problem? Thanks for the help.


import { Component } from '@angular/core';
import { NavParams } from 'ionic-angular';

@Component({
  	selector: 'tab1',
  	templateUrl: 'tab1.html'
})
export class Tab1Page {

  	constructor() {
		console.log('tab1');
	}
}

export class TabsPage {
userId: any;
noteId: any;

tab1: any;
tab2: any;
tab3: any;
tab4: any;	


constructor(public navCtrl: NavController, 
  			public alertCtrl: AlertController, 
			private noteService: NoteService,
			private userService: UserService,
			private loadingCtrl: LoadingController,
			public params:NavParams) {

	this.tab1 = Tab1Page;
	this.tab2 = Tab2Page;
	        this.tab3 = Tab3Page;
	this.tab4 = Tab4Page;

}

}



#2

I had several problems with Tab pages, until I came across the following thread, stating that a tabs page can only be the root (and not be pushed on the nav stack). This supposed to work in some earlier beta versions of Ionic 2, but down the road they changed the behaviour (and once you get used to it, it makes things easier).