首页 > 解决方案 > 如何使用 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中

标签: angular10

解决方案


您需要绑定到类以使用其中的变量。

<td *ngFor="let col of columnClass" class="pr-20" [class]="col">

推荐阅读