【发布时间】:2014-11-22 18:20:59
【问题描述】:
我正在使用 Ionic 框架开发一个应用程序,我只想在一些具体视图中显示一个侧面菜单,而不是在每个视图中。
我有我的 menu.html 文件:
<ion-side-menus>
<ion-pane ion-side-menu-content>
<ion-nav-bar class="bar-positive nav-title-slide-ios7">
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
</ion-pane>
<ion-side-menu side="left">
<ion-content class="mymenu">
<div id="menu-list">
<ion-list class="list">
<ion-item item-type="item-icon-left" nav-clear menu-close href="#">
<i class="icon ion-home"></i><span>Menu Item</span>
</ion-item>
...
</ion-list>
</div>
</ion-content>
</ion-side-menu>
</ion-side-menus>
我的 index.html 的 body 标签 看起来完全像这样:
<body ng-app="myApp">
<ion-nav-view></ion-nav-view>
</body>
以及我设置应用状态的 JavaScript 代码:
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app.page1', {
url: "/page1",
views: {
'menuContent' :{
templateUrl: "templates/page1.html"
}
}
})
.state('app.page2', {
url: "/page2",
views: {
'menuContent' :{
templateUrl: "templates/page2.html"
}
}
})
// etc...
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/page1');
});
page1.html 和 page2.html 都包含以下结构:
<ion-view title="something">
<ion-content>
... // here comes the html content of the page
</ion-content>
</ion-view>
我实际上可以做些什么来只在 page1.html 上而不是 page2.html 上显示我的侧边菜单 (menu.html) >??我有什么遗漏吗??
有没有办法只在我希望它出现的页面上插入 menu.html 内容而忘记创建将其用作templateUrl 的状态?
【问题讨论】:
标签: ionic-framework