ionic隱藏tabs的方法
本文為大家分享了ionic隱藏tabs的方法,供大家參考,具體內(nèi)容如下
1.
<ion-tabs ng-class="{'tabs-item-hide': $root.hideTabs}">
<!-- tabs -->
</ion-tabs>
2.
在該控制器下加上.directive:
var module = angular.module('app.directives', []);
module.directive('showTabs', function ($rootScope) {
return {
restrict: 'A',
link: function ($scope, $el) {
$rootScope.hideTabs = false;
}
};
}).directive('hideTabs', function ($rootScope) {
return {
restrict: 'A',
link: function ($scope, $el) {
$rootScope.hideTabs = true;
}
};
})
3.
在html頁面中引用hide-tabs
<ion-view title="New Entry Form" hide-tabs> <!-- view content --> </ion-tabs>
4.
當(dāng)頁面返回主頁面時,需要再次顯示tabs,則需要在該控制器中加上(主要是解決android上tabs還是隱藏的問題):
$scope.$on('$ionicView.enter', function () {
// 顯示 tabs
$rootScope.hideTabs = false;
});
5.
我用的是tabs-top,還遇到的一個問題是:<ion-content>的一部分內(nèi)容會被隱藏;解決辦法:
再次修改directive.js里邊的內(nèi)容,不再使用showTabs:
.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 = value;
});
});
scope.$on('$ionicView.beforeLeave', function () {
$rootScope.hideTabs = false;
});
}
};
})
來個總結(jié)吧,相對于tabs用法,如果是在底部的話,上邊的那些不會有什么太大的問題。但如果是用在頂部的話,涉及到content,會遇到一點(diǎn)問題。
其實(shí)可以考慮使用ionic上的<ion-slide>來代替<ion-tabs>,不管是與其它頁面的滑動效果,還是slide頁面的滑動效果都會很大的提升,特別是在android上。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS實(shí)現(xiàn)網(wǎng)頁Div層Clone拖拽效果
這篇文章主要介紹了JS實(shí)現(xiàn)網(wǎng)頁Div層Clone拖拽效果,涉及JavaScript響應(yīng)鼠標(biāo)事件動態(tài)改變頁面元素位置屬性及層級屬性的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09

