Changing tabs programatically


#1

Hi there

I need to change my tab programatically.

According to the documentation

this can be done by calling the select() on the tabs instance.

I get the error however that select does not exist on type Tabs

  @ViewChild('myTabs') tabRef: Tabs;

changeSlectedIndex(): void {
    this.tabRef.select(2)//red squiggly explaining does not exist on type Tabs

}

Am I missing something?

Thank you


#2

It depends where you are in your app:

If you are in a child component of the tab --> you need to do it this way:

switchTabs() {
  this.navCtrl.parent.switch(2);
}

#3

Cool, thank you…i did go that route in the end


#4

can we change tab in app.component(bootstrap component)?