在" ion-nav-bar"中显示/隐藏按钮关于观点

时间:2017-02-13 11:55:27

标签: angularjs ionic-framework ionic-view

我喜欢根据视图隐藏和显示图标。这是我无法做到的,因为ion-nav-bar只能从tabsCtrl

访问

以下是查看标记:

<ion-nav-bar class="bar-stable">
  <ion-nav-back-button> </ion-nav-back-button>
  <ion-nav-title>My App Title</ion-nav-title>
  <ion-nav-buttons side="right">
    <button class="button icon ion-ios-information-outline" ng-click="openFaqModal()" ng-hide="showHideFAQ"></button>
    <button class="button icon ci-bookmark" ng-click="openBoookmarkModal()" ng-show="showHideBookmark"></button>
  </ion-nav-buttons>
</ion-nav-bar>

这是控制器:

// Tab Controller - *** This Work ***
.controller('TabCtrl', function ($scope) {
  $rootScope.showHideFAQ = true;
  $rootScope.showHideBookmark = true;
})

// Detail Controller - *** This do not work ***
.controller('DetailCtrl', function ($scope) {
  $rootScope.showHideFAQ = true;
  $rootScope.showHideBookmark = true;
})

这是路线:

// setup an abstract state for the tabs directive
.state('tab', {
  url: '/tab',
  abstract: true,
  templateUrl: 'views/tabs.html',
  controller: 'TabCtrl'
})

.state('tab.detail', {
  url: '/resources/:resourcesId',
  views: {
    'tab-resources': {
      templateUrl: 'views/detail.html',
      controller: 'DetailCtrl'
    }
  }
})

我不知道为什么它会在&#34; TabCtrl&#34;但不是在&#34; DetailCtrl&#34;因为两个控制器都加载在一个视图中。我怀疑它与scope有关。

1 个答案:

答案 0 :(得分:0)

我正在使用$ionicView.leave// Detail Controller .controller('DetailCtrl', function ($scope, $ionicView) { // Show Bookmark and Hide FAQ icon $scope.$on('$ionicView.enter', function() { $rootScope.showHideFAQ = true; $rootScope.showHideBookmark = true; }); // Hide Bookmark and Show FAQ icon $scope.$on('$ionicView.leave', function() { $rootScope.showHideFAQ = false; $rootScope.showHideBookmark = false; }); }) 来解决我的问题:

pandas.DataFrame.plot()