[英]Ionic left sidemenu does not toggle open
嗨,我對ionic比較陌生,我正在嘗試同時運行帶有側面菜單和標簽欄的應用程序。 當前選項卡欄工作正常,當我單擊圖標時,左側菜單沒有打開。 對於大多數應用程序,我只是在ionic網站上研究了這些教程。
我正在將Google Maps添加到選項卡,並且我的目標是讓側欄的Facebook登錄,但主要問題是選項卡未切換。
$stateProvider
.state('menu', {
url: "/menu",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('menu.playlists', {
url: "/playlists",
views: {
'menu' :{
templateUrl: "templates/playlists.html",
controller: 'PlaylistsCtrl'
}
}
})
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tab.map', {
url: '/map',
views: {
'tab-map': {
templateUrl: 'templates/tab-map.html',
controller: 'MapCtrl'
}
}
})
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/map');
<ion-view view-title="Safety First">
<ion-nav-buttons side="left" ng-controller="AppCtrl">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content ng-controller="MapCtrl">
<div id="map" data-tap-disabled="true"></div>
</ion-content>
</ion-view>
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar-stable nav-title-slide-ios7">
<ion-nav-back-button class="button-clear"><i class="icon ion-ios7-arrow-back"></i> Back</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view name="menu" animation="slide-left-right"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left">
<header class="bar bar-header bar-stable">
<h1 class="title">Left</h1>
</header>
<ion-content class="has-header">
<ion-list>
<ion-item nav-clear menu-close href="#/app/about">
About
</ion-item>
<ion-item nav-clear menu-close ng-click="login()">
Login
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
這是應用程序主頁的圖像
當我單擊子菜單圖標時,它不會切換子菜單。 奇怪的是,如果我將應用程序導航到http:// localhost:8100 /#/ menu / playlists,則切換很好。
關於為什么沒有真正激發點擊的任何建議? 也許這是當時哪個控制器在起作用的問題?
您必須調用正確的函數。 我假設login()
位於AppCtrl
控制器內。 因此,除非您告訴它函數的位置,否則ng-click
找不到該函數。 由於AppCtrl
負責menu.html
,因此必須這樣調用它:
ng-click="this.login()"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.