如何根据离子条件启用侧面菜单

时间:2016-12-27 06:37:52

标签: angularjs ionic-framework

以下是我的HTML代码,用于启用使用离子框架的侧边菜单

<ion-side-menus enable-menu-with-back-views="false">
  <ion-side-menu-content>
    <ion-nav-bar class="bar bar-header bar-custom">
      <ion-nav-buttons side="left">
        <button class="button button-icon button-clear ion-navicon" menu-toggle="left"> </button>
      </ion-nav-buttons>
      <ion-nav-back-button class="button-clear" ng-click="myGoBack()"> <i class="ion-arrow-left-c"></i> </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view cache-view="false" class="roAppStyle" name="menuContent"></ion-nav-view>
  </ion-side-menu-content>
  <ion-side-menu side="left" expose-aside-when="large">
    <ion-header-bar class="bar-stable">
      <h1 class="title item-icon-left "> <i class="icon ion-person"></i>{{user.name}} </h1> </ion-header-bar>
    <ion-content>
      <ion-list>
        <ion-item ng-repeat="menu in sideMenuList" class="item item-icon-left" menu-close ng-click={{menu.method}}> <i class={{menu.icon}}></i> {{menu.label}} </ion-item>
        <!-- <ion-item class="item item-icon-left" menu-close ui-sref="app.home"> <i class="icon ion-ios-home"></i> Home </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToProducts()" > <i class="icon ion-egg"></i> Products </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToOrder()" > <i class="icon ion-android-cart"></i> Order </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToDeliveryAgent()" > <i class="icon ion-android-person"></i> Delivery Agent </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToOffers()" > <i class="icon ion-pricetags"></i> Offers </ion-item> -->
        <!-- <ion-item menu-close class="item item-icon-left" ui-sref="app.offers"> <i class="icon ion-pricetags"></i> Offers </ion-item> -->
        <ion-item class="item item-icon-left" ng-click="exitTheApp()"> <i class="icon ion-log-out"></i> Exit </ion-item>
      </ion-list>
    </ion-content>
  </ion-side-menu>
</ion-side-menus> 

客户代码:

app.controller('appCtrl', function($scope, $state, baseConstant, $ionicHistory, $ionicPopup, $rootScope, angularService, webSocketConnection) {
  $scope.goToProducts = function() {
    $state.go('app.product');
  }
  $scope.goToDeliveryAgent = function() {
    $state.go('app.deliveryAgent');
  }
  $scope.goToOffers = function() {
    $state.go('app.offers');
  }
  $scope.goToOrder = function() {
    $state.go('app.order');
  }
  $scope.goToDeliveryAcceptedOrder = function() {
    $state.go('app.deliveryacceptedOrders');
  }
  $scope.goToDeliveryCancelOrder = function() {
    $state.go('app.deliveryCancelOrders');
  }
  if ($rootScope.user.type === baseConstant.RO_USER_TYPE) {
    $scope.sideMenuList = baseConstant.roUserMenus;
    $state.go("app.product");
  }
  else if ($rootScope.user.type === baseConstant.DELIVERY_USER_TYPE) {
    $scope.sideMenuList = baseConstant.deliveryUserMenus;
    $state.go("app.deliveryacceptedOrders");
  }
  $scope.myGoBack = function() {
    $ionicHistory.goBack();
  };
  $scope.exitTheApp = function() {
    var confirmPopup = $ionicPopup.confirm({
      title: 'Alert',
      template: 'Are you sure you want to exit the app..?'
    });
    confirmPopup.then(function(res) {
      if (res) {
        var socketConnection = webSocketConnection.getWebSocketConnection(baseConstant.OFFLINE);
        navigator.app.exitApp();
      }
    });
  }
  $scope.imageUrl = baseConstant.IMAGE_URL;
});

当它是ro用户时,ro用户的第一个屏幕有菜单按钮但是当我注册为传递用户时,传递用户的第一个屏幕有后退按钮。我想要侧面菜单按钮

0 个答案:

没有答案