Search code examples
ionic-frameworkionic3ionic-tabs

Cant hide Ionic Tab first


I'm trying to create Ionic-3 Tab option, it's working fine, but my issue is I don't want to display 1st tab in tab menu,but I want to display 1st tab menu in page details in 1st time page opening ,I'm try to hide this 1st tab , but its not working for me, anyone knows how to do that?I have attached some images on my issue to help you understand it.

image

Tabs.html

<ion-tabs>
  <ion-tab [root]="tab0Root"></ion-tab>
  <ion-tab [root]="tab1Root" tabTitle="Check-In" tabIcon="people"></ion-tab>
  <ion-tab [root]="tab2Root" tabTitle="Observations" tabIcon="information-circle"></ion-tab>
  <ion-tab [root]="tab3Root" tabTitle="Activities" tabIcon="book"></ion-tab>
  <ion-tab [root]="tab4Root" tabTitle="Health" tabIcon="medkit"></ion-tab>
</ion-tabs>

Tabs.ts

import { Component } from '@angular/core';

import { AboutPage } from '../about/about';
import { ContactPage } from '../contact/contact';
import { HomePage } from '../home/home';
import {HealthPage} from '../health/health';
import {MainPage} from '../main/main';


@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {
  tab0Root = MainPage;
  tab1Root = HomePage;
  tab2Root = AboutPage;
  tab3Root = ContactPage;
  tab4Root = HealthPage;
  constructor() {

  }
}

Solution

  • Every Tab has it own show property. So just change it to false if you want to hide it.
    In tabs.ts:

    import { Component, ViewChild } from '@angular/core';
    import { Tabs } from 'ionic-angular';
    @ViewChild(Tabs) tabs: Tabs;
    ionViewDidEnter(){ 
        this.tabs.getByIndex(0).show = false; 
    }