raju
raju

Reputation: 6936

How to hide navbar in Ionic2

I am trying to hide in Ionic 2. I tried <ion-navbar [hidden]="true"> but it is not working.

Can anyone please tell me how to conditionally hide navbar in ionic2?

Upvotes: 1

Views: 898

Answers (1)

sebaferreras
sebaferreras

Reputation: 44659

You could use a property from your component to hide/show it

<ion-navbar *ngIf="showNavbar">

And in your component code:

import { Component, ViewChild } from '@angular/core';
import { Content } from 'ionic-angular';

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'
})
export class HomePage {

  @ViewChild(Content) content: Content;
  public showNavbar: boolean;

  // ...

  public hideNavbar(): void {
    this.showNavbar = false;

    // You should resize the content to use the space left by the navbar
    this.content.resize();
  }
}

Upvotes: 3

Related Questions