I have added side menu on two pages. None of them are home page. Toggling working for both the pages. But while navigate from one page to other page using side menu, toggling not working for the second page.
Here is my code for side menu for both pages
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item>
Job Codes
</button>
<button ion-item>
History
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav id="nav" #content [root]="rootPage"></ion-nav>
<ion-content>
<button ion-button menuToggle>Toggle Menu</button>
</ion-content>
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item>
Job Codes
</button>
<button ion-item>
History
</button>
</ion-list>
</ion-content>
</ion-menu>
now add this to your ts files
this.pages = [
{ title: 'Job Codes', component: JobCodesPage },
{ title: 'History', component: HistoryPage }
];
openPage(page) {
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
That should do the trick
After i remove
<ion-nav id="nav" #content [root]="rootPage"></ion-nav>
from HTML code toggling not working…
Oops please add it. I skipped that
Where is need to add these lines…??
In app.component.ts or to the particular page’s ts…?
Codebot:
this.pages = [
{ title: ‘Job Codes’, component: JobCodesPage },
{ title: ‘History’, component: HistoryPage }
];
openPage(page) {
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
Codebot
December 11, 2017, 3:37pm
7
Particular ts page in the project
there is a sample sidemenu ionic Project.
ionic start myApp sidemenu
maybe this helps.
But i want to add sidemenu on a existing project. And i don’t need sidemenu on every page.
this.menu.enable(false);
Call this in a page’s contructor to disable menu.
You should still look into the template and copy paste it.
The documentation about menus is kinda weak and confusing.
Yes. But it is very tedious work to recreate a existing project with ionic start myApp sidemenu
Still menu toggling not working in the 2nd page. When i navigate from 1st page using side menu.