angular4 – 如何在角度4中使用其他
发布时间:2020-12-17 07:40:55 所属栏目:安全 来源:网络整理
导读:我使用角度4,我想在这个例子中使用ngIf else: div *ngIf="isValid" content here .../divdiv *ngIf="!isValid" other content here.../div 如何用其他方式实现相同的行为? 角4.0.0决赛: 使用其他: div *ngIf="isValid;else other_content" content here
我使用角度4,我想在这个例子中使用ngIf else:
<div *ngIf="isValid"> content here ... </div> <div *ngIf="!isValid"> other content here... </div> 如何用其他方式实现相同的行为?
角4.0.0决赛:
使用其他: <div *ngIf="isValid;else other_content"> content here ... </div> <ng-template #other_content>other content here...</ng-template> 你也可以使用其他的: <div *ngIf="isValid;then content else other_content">here is ignored</div> <ng-template #content>content here...</ng-template> <ng-template #other_content>other content here...</ng-template> 或者一个人: <div *ngIf="isValid;then content"></div> <ng-template #content>content here...</ng-template> 演示: Plunker 细节: <纳克模板> :是Angular自己实现的< template>标签根据MDN:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |