Ionic hiding tabs method, ionic hiding tabs Method

Source: Internet
Author: User

Ionic hiding tabs method, ionic hiding tabs Method

This article shares with you the ionic hidden tabs Method for your reference. The specific content is as follows:

1.

 <ion-tabs ng-class="{'tabs-item-hide': $root.hideTabs}"><!-- tabs --></ion-tabs> 

2.
Add. directive under the controller:

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.
Reference hide-tabs on the html page

<ion-view title="New Entry Form" hide-tabs>  <!-- view content --></ion-tabs> 

4.

When the page returns to the home page, you need to display tabs again, you need to add in the Controller (mainly to solve the problem of tabs or hidden on android ):

$ Scope. $ on ('$ ionicView. enter', function () {// display tabs $ rootScope. hideTabs = false ;});

5.
I used tabs-top and encountered another problem: some content of <ion-content> will be hidden. solution:
Modify the content in directive. js again and stop using 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;      });    }  };}) 

To sum up, compared with the tabs usage, if it is at the bottom, there will be no major problems above. However, if it is used on the top, it involves content and may encounter some problems.

In fact, you can consider using <ion-slide> on ionic to replace <ion-tabs>, whether it is sliding with other pages or slide pages, it will be greatly improved, especially on android.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.