I did as you wrote but it does not work. Please look at my example:
app.js
import {App, IonicApp, Platform} from 'ionic/ionic';
import {FirstPage} from './first/first';
import {SecondPage} from './second/second';
@App({
templateUrl: 'app/app.html'
})
class MyApp {
constructor(app: IonicApp, platform: Platform) {
this.app = app;
this.platform = platform;
this.initializeApp();
this.pages = [
{ title: "First Page", component: FirstPage },
{ title: "Second Page", component: SecondPage }
];
this.rootPage = FirstPage;
}
initializeApp() {
this.platform.ready().then(() => {
console.log('Platform ready');
});
}
openPage(page) {
let nav = this.app.getComponent('nav');
nav.setRoot(page.component);
}
}
app.html
<ion-menu [content]="content" side="left" id="testLeftMenu">
<ion-toolbar>
<ion-title>Left menu</ion-title>
</ion-toolbar>
<ion-content>
<ion-list>
<ion-list-header>Pages</ion-list-header>
<button menuClose ion-item *ngFor="#p of pages" (click)="openPage(p)">
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav id="nav" [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
first.js
import {IonicApp, Page, NavController, NavParams} from 'ionic/ionic';
@Page({
templateUrl: 'app/first/first.html'
})
export class FirstPage {
constructor(app: IonicApp, nav: NavController, navParams: NavParams) {
this.nav = nav;
// If we navigated to this page, we will have an item available as a nav param
this.selectedItem = navParams.get('item');
}
}
first.html
<ion-navbar *navbar>
<button menuToggle="testLeftMenu">
<icon menu></icon>
</button>
<ion-title>First Page</ion-title>
<button menuToggle="testRightMenu">
<icon menu></icon>
</button>
</ion-navbar>
<ion-menu [content]="content" side="right" id="testRightMenu">
<ion-toolbar>
<ion-title>First right menu</ion-title>
</ion-toolbar>
<ion-content>
First right menu body
</ion-content>
</ion-menu>
<ion-content>
<ion-card>
<ion-card-content>
First page content
</ion-card-content>
</ion-card>
</ion-content>
second.js
import {IonicApp, Page, NavController, NavParams} from 'ionic/ionic';
@Page({
templateUrl: 'app/second/second.html'
})
export class SecondPage {
constructor(app: IonicApp, nav: NavController, navParams: NavParams) {
this.nav = nav;
// If we navigated to this page, we will have an item available as a nav param
this.selectedItem = navParams.get('item');
}
}
second.html
<ion-navbar *navbar>
<button menuToggle="testLeftMenu">
<icon menu></icon>
</button>
<ion-title>Second Page</ion-title>
<button menuToggle="testRightMenu">
<icon menu></icon>
</button>
</ion-navbar>
<ion-menu [content]="content" side="right" id="testRightMenu">
<ion-toolbar>
<ion-title>Second right menu</ion-title>
</ion-toolbar>
<ion-content>
Second right menu body
</ion-content>
</ion-menu>
<ion-content>
<ion-card>
<ion-card-content>
Second page content
</ion-card-content>
</ion-card>
</ion-content>