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