Javascript Angular2在动态列中循环
我正在使用angular2和*ngFor构建一个动态表,如下所示,但我无法看到数据。我不确定{{x[col]}}是否正确,知道吗Javascript Angular2在动态列中循环,javascript,angular,Javascript,Angular,我正在使用angular2和*ngFor构建一个动态表,如下所示,但我无法看到数据。我不确定{{x[col]}}是否正确,知道吗 <tr *ngFor="let x of exportList"> <td *ngFor="let col of cols"> {{x[col]}} </td> </tr> {{x[col]} 您需要遍历内部循环中的每一行。 尝试:
<tr *ngFor="let x of exportList">
<td *ngFor="let col of cols">
{{x[col]}}
</td>
</tr>
{{x[col]}
您需要遍历内部循环中的每一行。
尝试:
{{col}}
{{col}}
您只需要用x替换cols。exportList包含多个对象。因此,在x中,每个循环中都有一个对象。通过使用对象,您可以获取每个字段。您的数据格式是什么样的?请检查此项
<tr *ngFor="let rows of exportList">
<td *ngFor="let col of rows">
{{col}}
</td>
</tr>
<tr *ngFor="let x of exportList">
<td *ngFor="let col of x">
{{col}}
</td>
</tr>