I tried to find a way to show tabs in side menu pages. it is easily possible to show side menu on tabs page but in side menu pages I couldn’t show tabs.
all examples shows that two different things side menus are the same pages tat tabs references. or like mine code tabs are showing side menus but side menus page could not the tabs.
Any idea is how to solve it, I couldn’t find any way.
No but I found that structurally seems it is impossible. you can show side menu in tab pages but when using side menu it completely different route and navigation using. regarding to tabs.ts and html
@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() {
}
}
Try Setting below in your launch page.ts (launch page is a root page set at apps.component.ts file ) file.
this.navCtrl.setRoot(MenuTogglePage);
For example: my launch page is login page of app. Once I login, above code will set root page as MenuTogglePage (menutoggle page is a page where I defined my code for side menu).
Also it has nothing to do with Tabs Page. So none changes are required in that files.
import { Component } from '@angular/core';
import { Page1 } from '../pages/page1/page1';
import { Page2 } from '../pages/page2/page2';
import { NavController } from 'ionic-angular';
import { HomePage } from '../home/home';
import { AboutPage } from '../about/about';
import { ContactPage } from '../contact/contact';
@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( public navCtrl: NavController ) {
}
}
and by default tab1root goes to homepage home.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<h2>Welcome to Ionic!</h2>
<p>
This starter project comes with simple tabs-based layout for apps
that are going to primarily use a Tabbed UI.
</p>
<p>
Take a look at the <code>src/pages/</code> directory to add or change tabs,
update any existing page or create new pages.
</p>
</ion-content>
home.ts
import { Component } from ‘@angular/core’;
As I said navigation from side menu is completely independent of tabs menu. it is easy to show side menu in tabs page but wen changing page to side menu’s pages it will not show back button or tabs menu below the page.
It simply can not work with standard implementation of ionic2. You’ll need to create your own version of the menu. Sad fact that ionic team failed to foresee this major major use case for side-menu and tabs.