我有动态增长的html表,我想基于它的值动态地为列的背景提供特定的颜色,这样做的最佳方法是什么,而不使用显示表的数据的数组的额外变量?
您可以使用如下所示的ngStyle,
<td [ngStyle]="{'background-color':person.country === 'UK' ? 'green' : 'red' }"></<td>