我這樣設定條件:
<mat-chip-list>
<mat-chip color="accent" *ngIf="letter.status == 'Completed'" selected>
{{ letter.status }}
</mat-chip>
<mat-chip color="warn" *ngIf="letter.status == 'In Work'" selected>
{{letter.status }}
</mat-chip>
</mat-chip-list>
是否可以減少它,使其看起來像這樣:
<mat-chip color="letter.status == 'Completed' ? accent : warn" selected>
{{ letter.status }}
</mat-chip>
uj5u.com熱心網友回復:
@Input() color: ThemePalette Theme color palette for the component.
顏色是一個輸入屬性
color="accent"靜態
[color]="expr ? 'accent' : 'warn'"動態
<mat-chip-list>
<mat-chip
[color]="letter.status == 'Completed' ? 'accent' : 'warn'"
selected
selected
>
{{ letter.status }}
</mat-chip>
</mat-chip-list>
堆疊閃電戰
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/413236.html
標籤:
