我想从一个标签按钮打开sidemenu。 控制台输出“打开菜单”,所以我知道服务方法被调用,但它根本不会打开菜单。 我在哪里去了?
这是我的tabs.html
<ion-tabs class="tabs-super-top tabs-top tabs-icon-left tabs-striped">
<ion-tab title="More" icon="icon ion-navicon" ng-click="openSideMenu()" >
</ion-tab>
<ion-tab title="Events" icon="icon ion-calendar" ui-sref="tab.events">
<ion-nav-view name="tab-events" class="slide-left-right" ion-side-menu-content></ion-nav-view>
</ion-tab>
<ion-tab title="Involved" icon="icon ion-checkmark-round" ui-sref="tab.involved">
<ion-nav-view name="tab-involved" class="slide-left-right" ion-side-menu-content></ion-nav-view>
</ion-tab>
<ion-tab title="Networks" icon="icon ion-network" ui-sref="tab.networks">
<ion-nav-view name="tab-networks" class="slide-left-right" ion-side-menu-content></ion-nav-view>
</ion-tab>
</ion-tabs>
navigation.js模块:
angular.module('navigationModule', [])
.controller('SideMenuController', function($scope, sideMenuService)
{
$scope.openSideMenu = function()
{
sideMenuService.openSideMenu('sideMenu');
};
})
.service('sideMenuService', function($ionicSideMenuDelegate) {
return {
openSideMenu: function(menuhandle)
{
console.log('open menu');
return $ionicSideMenuDelegate.$getByHandle(menuhandle).toggleLeft();
}
}
})
;
目前,我有我的sidemenu index.html中:
<ion-side-menus side="left" delegate-handle="sideMenu">
<!-- Center content -->
<ion-side-menu-content>
<ion-list>
<ion-item nav-clear menu-close ng-click="login()">Login</ion-item>
<ion-item nav-clear menu-close href="#/app/search">Search</ion-item>
<ion-item nav-clear menu-close href="#/app/browse">Browse</ion-item>
<ion-item nav-clear menu-close href="#/app/playlists">Playlists</ion-item>
</ion-list>
</ion-side-menu-content>
<!-- Left menu -->
<ion-side-menu side="left"></ion-side-menu>
<!-- Right menu -->
<ion-side-menu side="right"></ion-side-menu>
</ion-side-menus>
这是我的状态:
$stateProvider
.state('tab', {
url: "/tab",
abstract: true,
templateUrl: "templates/common/Tabs.html",
controller: 'SideMenuController'
})