zoukankan      html  css  js  c++  java
  • ionic隐藏tabs方法

    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.

    当页面返回主页面时,需要再次显示tabs,则需要在该控制器中加上(主要是解决android上tabs还是隐藏的问题):

    $scope.$on('$ionicView.enter', function () {
        // 显示 tabs
        $rootScope.hideTabs = false;
    });

     5.

    我用的是tabs-top,还遇到的一个问题是:<ion-content>的一部分内容会被隐藏;解决办法:

    再次修改directive.js里边的内容,不再使用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;
                });
            }
        };
    })

    来个总结吧,相对于tabs用法,如果是在底部的话,上边的那些不会有什么太大的问题。但如果是用在顶部的话,涉及到content,会遇到一点问题。

    其实可以考虑使用ionic上的<ion-slide>来代替<ion-tabs>,不管是与其它页面的滑动效果,还是slide页面的滑动效果都会很大的提升,特别是在android上。 

  • 相关阅读:
    OpenEuler下OpenSSL的安装
    《Unix/Linux系统编程》第四章学习笔记
    缓冲区溢出实验
    2.3.1测试
    鲲鹏服务器测试
    第六章学习笔记(20191213兰毅达)
    第五章学习笔记(20191213兰毅达)
    stat命令的实现-mysate(20191213兰毅达)
    反汇编测试(20191213兰毅达)
    OpenEuler树莓派基础实验
  • 原文地址:https://www.cnblogs.com/maoyazhi/p/4424039.html
Copyright © 2011-2022 走看看