如何在离子侧菜单中添加子菜单?我已经为侧面菜单
完成了以下代码app.html
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
app.compact.ts
import { Component ,ViewChild} from '@angular/core';
import { Platform ,Nav} from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Dashboard } from '../pages/dashboard/dashboard';
import { LineBoy } from '../pages/line-boy/line-boy';
import { Customer } from '../pages/customer/customer';
import { DeliveryLine } from '../pages/delivery-line/delivery-line';
import { Newspaper } from '../pages/newspaper/newspaper';
import { Scheme } from '../pages/scheme/scheme';
import { Expenses } from '../pages/expenses/expenses';
import { Report } from '../pages/report/report';
import { Billing } from '../pages/billing/billing';
import { Settings }from '../pages/settings/settings';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = Dashboard;
@ViewChild(Nav) nav: Nav;
pages: Array<{title: string, component: any}>;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
this.pages = [
{ title: 'Dashboard', component: Dashboard },
{ title: 'LineBoy', component: LineBoy },
{ title: 'DeliveryLine', component: DeliveryLine },
{ title: 'Customer', component: Customer },
{ title: 'Newspaper', component: Newspaper },
{ title: 'Scheme', component: Scheme },
{ title: 'Expenses', component: Expenses },
{ title: 'Report', component: Report },
{ title: 'Billing', component: Billing },
{ title: 'Settings', component: Settings },
];
}
openPage(page) {
this.nav.setRoot(page.component);
}
}