[SOLVED] Selected the right tab after press a button

I can’t think of a situation where it would make any sense to directly push a page that is a child of a tabbed page. I’m going to assume you mean you want the buttons on the home page to affect the selected tab.

openSong(): void {
  this.navCtrl.setRoot(HometabPage, {opentab: 1});
}

openNews(): void {
  this.navCtrl.setRoot(HometabPage, {opentab: 2});
}

openBio(): void [
  this.navCtrl.setRoot(HometabPage, {opentab: 3});
}

HometabPage {
  seltabix: number;

  constructor(np: NavParams) {
    this.seltabix = np.get('opentab');
  }
}

<ion-tabs [selectedIndex]="seltabix">

Incidentally, lose [HttpProvider]. You don’t want per-page instances of that.

3 Likes