如何根据布尔值交换内容?

我想根据布尔值是真还是假来交换我的 page.html 中的一些内容。所以我看到你可以用 来创造这样的东西,<ng-content>但不知何故这并没有奏效。我收到此错误:Error: Template parse errors: <ng-content> element cannot have content.我还注意到必须有某种方法可以删除旧内容。


页面.html


      <ion-card>

    <!--  content to move away when bool true-->

        </ion-card>


    <div *ngIf="!checked">

    <ng-content>

      <ion-card>

<!-- new content when bool false-->

</ion-card>

    </ng-content> 

      </div>       


慕妹3146593
浏览 184回答 1
1回答

互换的青春

有两个单独的条件对你有用吗?<ion-card *ngIf="checked">&nbsp; &nbsp; <!--&nbsp; content to move away when bool true--></ion-card><ion-card *ngIf="!checked">&nbsp; &nbsp; <!-- new content when bool false--></ion-card>如果这不起作用,您可以使用开关<div [ngSwitch]="checked">&nbsp; &nbsp; <ion-card *ngSwitchCase="true">&nbsp; &nbsp; &nbsp; &nbsp; <!--&nbsp; content to move away when bool true-->&nbsp; &nbsp; </ion-card>&nbsp; &nbsp; <ion-card *ngSwitchCase="false">&nbsp; &nbsp; &nbsp; &nbsp; <!-- new content when bool false-->&nbsp; &nbsp; </ion-card></div>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript