Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I hide the tabs in Ionic Framework

I chose the ionic tab view so I can use the templating system but I can't remove the tabs. I want a view like this and I did manage to remove the header bar but I cant remove the tabs bar

enter image description here

This is what I got so far:

enter image description here

If I hide the tabs bar (ion-tabs{display:none}) it also removes the content, which is not what I want.

like image 725
Sinan Samet Avatar asked Jun 02 '14 09:06

Sinan Samet


People also ask

How do you hide tabs in ionic?

There is a simple way to implement that - moving the route you wish to hide the tab-bar to the tabs module, outside of tabs children routes. Moving this route to tabs routing module will hide tab-bar from the page.

How do you hide tabs in ionic 3?

If you want to hide the tabbar then do this line of code: tabs[key]. style. display = 'none';

How do you change tabs in ionic?

All tabs can be changed by setting the value of tabsLayout on the <ion-tabs> element, or in your app's config. For example, this is useful if you want to show tabs with a title only on Android, but show icons and a title for iOS.

How do you use ionic tabs?

We can easily navigate between each view by clicking on the tab label. Each tab's label is shown in the ion-tab-bar and the active tab's label is designated with a different style. The Ionic tabs are mainly used for mobile navigation and we have to see tabs are commonly used at bottom of an application.


2 Answers

I know that this is answered already, but there's a more "angular way" of doing this that might be helpful. It's done by using a custom directive that you can apply on views that you don't want to show the bottom tab bar.

My solution to this on my app was:

1 - Use ng-hide binded to a rootScope variable on the tab bar, so I can hide/show it in any Controller/View of my app:

<ion-tabs ng-hide="$root.hideTabs" class="tabs-icon-only">
    <!-- tabs -->
</ion-tabs>

2 - Create a custom directive that, when present, will hide the tab bar (and will show the tab bar again when the view is destroyed/dismissed:

var module = angular.module('app.directives', []);
module.directive('hideTabs', function($rootScope) {
    return {
        restrict: 'A',
        link: function($scope, $el) {
            $rootScope.hideTabs = true;
            $scope.$on('$destroy', function() {
                $rootScope.hideTabs = false;
            });
        }
    };
});

3 - Apply it to specific views that don't need the tab bar visible:

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

ps: I think this can be improved even further avoiding the need of the ng-hide on the <ion-tabs> declaration, letting the directive do all the "dirty work".

like image 131
Daniel Rochetti Avatar answered Nov 13 '22 22:11

Daniel Rochetti


Have a look at the Ionic tab documentation:

To hide the tabbar but still show the content, add the "tabs-item-hide" class.

So you would change this:

<div class="tabs">
  <a class="tab-item" href="#">
    Home
  </a>
  ...
</div>

to this:

<div class="tabs tabs-item-hide">
  <a class="tab-item" href="#">
    Home
  </a>
  ...
</div>
like image 37
Sly_cardinal Avatar answered Nov 13 '22 22:11

Sly_cardinal