【发布时间】:2017-09-11 11:37:17
【问题描述】:
我试图隐藏在 Ionic 2 中。我尝试了 <ion-navbar [hidden]="true">,但它不起作用。
谁能告诉我如何有条件地隐藏 ionic2 中的导航栏?
【问题讨论】:
标签: angular typescript ionic2 ionic3
我试图隐藏在 Ionic 2 中。我尝试了 <ion-navbar [hidden]="true">,但它不起作用。
谁能告诉我如何有条件地隐藏 ionic2 中的导航栏?
【问题讨论】:
标签: angular typescript ionic2 ionic3
您可以使用组件中的属性来隐藏/显示它
<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();
}
}
【讨论】: