在有tabs的項目裡,進入子層級時,底部導航還一直存在,本人是要讓他只在首頁幾個界面存在,其他的隱藏,在這裡用到了angularjs的指令,要完成這個步驟分為三步:
在標簽ion-tabs中添加:ng-class=”{‘tabs-item-hide': $root.hideTabs}”,源碼如下
<ion-tabs class="tabs-icon-top" ng-class="{'tabs-item-hide': $root.hideTabs}">
//tabs
</ion-tabs>
添加angularjs的指令,源碼如下:
//app已經在其他文件中指定,如var app = angular.module("starter",["ionic"])
app.directive('hideTabs', function($rootScope) {
return {
restrict: 'A',
link: function(scope, element, attributes) {
scope.$on('$ionicView.beforeEnter', function() {
scope.$watch(attributes.hideTabs, function(value){
$rootScope.hideTabs = 'tabs-item-hide';
});
});
scope.$on('$ionicView.beforeLeave', function() {
scope.$watch(attributes.hideTabs, function(value){
$rootScope.hideTabs = 'tabs-item-hide';
});
scope.$watch('$destroy',function(){
$rootScope.hideTabs = false;
})
});
}
};
});
在想要隱藏的界面標簽 ion-view添加表達式hide-tabs=”true”,源碼如下:
//這是官網模板中的文件
<ion-view hide-tabs="true" view-title="{{chat.name}}">
<ion-content class="padding">
<img ng-src="{{chat.face}}" style="width: 64px; height: 64px">
<p>
{{chat.lastText}}
</p>
</ion-content>
</ion-view>
以上所述是小編給大家介紹的ionic進入多級目錄後隱藏底部導航欄(tabs)的完美解決方案,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對網站的支持!