【发布时间】:2020-01-17 16:55:14
【问题描述】:
我有一个接受输入的组件..@Input() coDeliveryCandidates: DeliverySlotView[];
这是在模板中使用的:
<ng-container *ngFor="let coDeliverySlotView of (coDeliveryCandidates | async)">
<button
mat-raised-button
[color]=""
>
{{ label }}
</button>
</ng-container>
color 属性将字符串作为值,我想做类似的事情:
[color]="{
black: coDeliverySlotView.slotId === bookedSlot.slotId,
grey: !coDeliverySlotView.slotId === bookedSlot.slotId
}"
这里我使用与 ngClass 相同的语法,但我猜它不支持这种方式.. 那么还有其他类似的方式吗? :)
【问题讨论】:
标签: angular angular-material conditional-statements angular-components