html 角度5 ngIf / else
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 角度5 ngIf / else相关的知识,希望对你有一定的参考价值。
<p *ngIf="serverCreated; else noServer">Server was created, server name is {{ serverName }}!</p>
<ng-template #noServer>
<p>No server was created!</p>
</ng-template>
<p
[ngStyle]="{'background-color': getColor()}"
[ngClass]="{'online': serverStatus === 'online' }"
>The Server {{ serverId }} is {{ getServerStatus() }}!</p>
<app-server *ngFor="let server of servers"></app-server>
<!-- Sample -->
<button (click)="display = !display; addLog()">Display Details</button>
<p *ngIf="display">Secret Password = tuna</p>
<p
*ngFor="let log of logs; let i = index"
[ngStyle]="{'background-color': (i>=5) ? 'blue': 'transparent'}"
[ngClass]="{'advanced': i>=5}">{{ log }}</p>
以上是关于html 角度5 ngIf / else的主要内容,如果未能解决你的问题,请参考以下文章
html ngif-else.html
html * ngIf else
html ngif-异步-AS-else.html
*ngIf-else 不显示 else 结果
如何使用“*ngIf else”?
角度 4: *ngIf 有多个条件