angular10 - 如何使用 angular10 通过 *ngFor 循环类名
问题描述
columnClass: string[] = ['name', 'email', 'phn', 'city', 'state', '', 'w-40'];
<td *ngFor="let col of columnClass" class="pr-20 {{col}}">
string[]
在一个component.ts中,html
在另一个component.html中
解决方案
您需要绑定到类以使用其中的变量。
<td *ngFor="let col of columnClass" class="pr-20" [class]="col">