有条件地设置 mdButton 属性

setting mdButton attributes conditionally

按照要求,我想设置按钮在激活时使用强调色突出显示。

类似于

<button md-button *ngFor="let item of items" [attr.color]="item.caption == activeItem ? 'accent' : ''">

或者类似

<button md-button *ngFor="let item of items" color="{{ item.activeColor }}"

我在Angular 1 中似乎可以这样做,但在Angular 2 中没有效果。

有人可以帮忙吗?

谢谢

我认为你必须设置 color 与下面相同,因为 color@Input 属性 根据 documentation :

<button md-button *ngFor="let item of items" [color]="item.caption ==  activeItem ? 'accent' : ''">