应用程序组件.ts
platformReady() {
// Call any initial plugins when ready
this.platform.ready().then(() => {
if(this.platform.is('core')){
// this.menu.enable(false, 'mobileOnlyPages');
}else{
this.splashScreen.hide();
}
});
}
app.templates.html
<button ion-item menuClose *ngFor="let p of mobileOnlyPages" (click)="openPage(p)" ngHide="mobile_only">
<ion-icon item-start [name]="p.icon" [color]="isActive(p)"></ion-icon>
{{p.title}}
</button>
我如何隐藏加载时的这个按钮?
最佳答案
您可以使用:
*ngIf="mobile_only"
或:
[class.hidden]="mobile_only"
在你的样式表上:
.hidden { display: none; }
编辑:
*ngIf
是一种:“如果 ____ 则呈现此 html 标记”
同时
[class.myClassName]
将是:“Apply class, myClassName, on this html tag if ____”
所以基本上可能存在这样一种情况,您实际上出于某种原因需要呈现标签,但只是对用户隐藏了。在那种情况下,使用“条件类”。这不是最好的解释,但我希望这足够有意义。
这是我所说的可能情况的一个例子: Ionic2 button click text box toggle
关于typescript - ionic : How do I hide an element on load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46120999/