typescript - ionic : How do I hide an element on load

标签 typescript ionic-framework ionic3

应用程序组件.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/

相关文章:

android - 禁用 ionic 列表滚动

javascript - 切换翻译术语

javascript - 在编辑模式下执行 CRUD 操作时选择 ionic 选择选项

typescript - TS2339 - 'Property doesn' t 存在于明显有效的 TS 文件中的类型错误

asp.net - 使用 Visual Studio 2015 在 gulp 中检测发布/调试

angularjs - 如何在node.js "html page"中显示json stringify数组数据?

angular - 固定 ionic 3 : property 'questions' does not exist on type 'Object'

cordova - 配置项目 ':CordovaLib' 时出现问题

angular - 源具有X个元素,但目标仅允许1个

reactjs - Cypress 在我的 ts 文件旁边添加了 js 文件