我正在使用 Ionic Framework 开发一个应用程序,我只想在一些具体视图中显示侧面菜单,而不是在每个视图中。
我有我的菜单.html file:
<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>
My 索引.html's body tag看起来就像这样:
<body ng-app="myApp">
<ion-nav-view></ion-nav-view>
</body>
And the 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');
});
第1页.html and page2.html两者都包含以下结构:
<ion-view title="something">
<ion-content>
... // here comes the html content of the page
</ion-content>
</ion-view>
我实际上可以做什么来只显示我的侧菜单(菜单.html) on 第1页.html并且不在page2.html??我有什么遗漏的吗?
有没有办法插入菜单.html仅在那些页面上显示我希望它出现的内容,并忘记创建使用它的状态templateUrl
?