【问题标题】:Ionic 4: “destroy” ngIf once expression is trueIonic 4:一旦表达式为真,“销毁”ngIf
【发布时间】:2019-05-16 05:03:29
【问题描述】:

我正在寻找类似 @​​987654321@ 的东西,但对于 Ionic 4:

我想知道是否可以取消绑定/销毁 ng-if 一旦它的值 是真的吗?

【问题讨论】:

标签: angular ionic4


【解决方案1】:

不是问题的确切答案,但它可能会帮助正在寻找此解决方案的人:

我试图使用 ngIf 仅显示一次标题,用于一组 o 项,但前提是有要显示的项...我最终做的是以下内容:

        <p [hidden]="!showedOnce">Some header</p> 
        <div *ngFor="let task of tasks; let taskIndex = index">
            <span *ngIf="taskIndex > 0">{{setShowedOnce()}}</span>
            <ion-item>
              <ion-label>{{task.title}}</ion-label>
            </ion-item>
        </div>

在组件中:

showedOnce: boolean

ngOnInit() {
    this.showedOnce = false
}

setShowedOnce() {
    this.showedOnce = true
}

【讨论】:

    猜你喜欢
    • 2016-03-04
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    • 2011-08-18
    • 2018-12-17
    • 1970-01-01
    • 2015-03-03
    • 1970-01-01
    相关资源
    最近更新 更多