Hello, I have a use-case where I want to modify another tab’s navigation hierarchy from within the class of a different tab.
Here is a sample I created with the tabs starter project:
<ion-tabs>
<ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>
</ion-tabs>
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
// this tells the tabs component which Pages
// should be each tab's root Page
tab1Root: any = HomePage;
tab2Root: any = AboutPage;
tab3Root: any = ContactPage;
constructor() {
}
}
Inside of HomePage.ts I have the following code for a button click:
public changeTabAndPushToStack(){
// select tab index 1
this.app.getRootNav().getActiveChildNav().select(1);
// push ContactPage within tab index 1:
this.app.getRootNav().getActiveChildNav()._tabs[1]._views[0]._nav.push(ContactPage)
}
While the above works when I click on the button on HomePage (it selects the AboutPage tab, and pushed ContactPage within that tab), but that last line of code is very ugly.
Is there a cleaner way to do this?