我正在尝试将一组类添加到一行中。我的问题是重复该行。所以我的问题是如何在 [ngClass]
我的代码不起作用。
.ts
@Input() rowClasses = ['someClass1', 'someClass2']
html
<table>
<thead>
<tr>
<th>some head</th>
</tr>
</thead>
<tbody>
<tr class="striped-row" *ngFor="class of rowClasses" [ngClass]="class"></tr>
</tbody>
</table>
最佳答案
你不需要 for-loop 你只需要直接将你的数组分配给 ngClass 示例:
[ngClass]="rowClasses"
或
[ngClass]="['someClass1', 'someClass2']"
关于angular - 将数组添加到 ngclass angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41104271/