2017-04-15 152 views
1

我想隱藏在Ionic 2中。我嘗試了<ion-navbar [hidden]="true">,但它不起作用。如何隱藏Ionic2中的導航欄

任何人都可以請告訴我如何有條件地隱藏在ionic2的導航欄?

回答

2

你可以使用一個屬性從您的組件隱藏/顯示它

<ion-navbar *ngIf="showNavbar"> 

而在你的組件代碼:

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(); 
    } 
} 
+0

賓果。非常感謝先生。 – raju

+0

很高興幫助:) – sebaferreras