There are two tabs in my app. On the <ion-menu>
there are links for both tabs. When I click on the Tab1
button the first tab is open and it’s OK.
But when I click on the Tab2
I need to show the tab2Page on the tabsPage, but if I try:
this.nav.setRoot(tabs2Page)
The page is shown without tabs.
How can I go to the second tab from the side menu?
app.html
:
<ion-menu [content]="nav">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item (click)="onLoad(tabsPage)">
<ion-icon name="book" item-left></ion-icon>
Tab1
</button>
<button ion-item (click)="onLoad(tab2)">
<ion-icon name="list-box" item-left></ion-icon>
Tab2
</button>
<button ion-item (click)="onLoad(settingsPage)">
<ion-icon name="settings" item-left></ion-icon>
Configurações
</button>
</ion-list>
</ion-content>
</ion-menu>
app.component.ts
:
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
tabsPage = TabsPage;
tab2 = Tab2Page;
settingsPage = SettingsPage;
//...
onLoad(page: any) {
this.nav.setRoot(page);
this.menuCtrl.close();
}
}
tabs.html
<ion-tabs tabsPlacement="top" #appTabs>
<ion-tab [root]="tab1page" tabIcon="book"></ion-tab>
<ion-tab [root]="tab2Page" tabIcon="list-box"></ion-tab>
</ion-tabs>