1.指令代码
1 directiveMod.directive('hideTabs',function($rootScope){ 2 return { 3 restrict:'AE', 4 link:function($scope){ 5 $scope.$on('$ionicView.beforeEnter', function() { 6 $rootScope.hideTabs = 'tabs-item-hide'; 7 8 console.log('tabs-item-hide'); 9 10 }); 11 $scope.$on('$destroy',function(){ 12 $rootScope.hideTabs = ''; 13 console.log('no-tabs-item-hide'); 14 15 }) 16 } 17 } })
2.使用示例:
app.js
angular.module('starter', ['ionic','starter.controllers','starter.directive'])
tabs.html
1 <ion-tabs class="tabs-icon-top tabs-color-active-positive {{hideTabs}}"> 2 </ion-tabs>
1 <ion-view hide-tabs title="详情"> 2 ...... 3 </ion-view>