【发布时间】:2023-03-21 05:12:02
【问题描述】:
我正在从 API 获取列名未知的数据。我能够绑定表头但无法绑定 tbody 行的列.. 例如,数据将是这样的。
[{name: "jean", surname: "kruger"}, {name: "bobby", surname: "marais"}];
OR
[{name: "jean", email: "a@a.com"}, {name: "bobby", email: "b@b.com"}]; // anything
<table>
<thead>
<tr><th *ngFor="let col of headers">{{col}}></th></tr>
</thead>
<tbody>
<tr *ngFor="let obj of data">
<td *ngFor="let col of headers"> {{obj[col]}} </td> // Its not working
OR
<td *ngFor="let col of headers"> {{obj.col}} </td> // Its not working, will be column sequence mapping issue
</tr>
</tbody>
</table>
**如何解决这个问题? 谢谢.. **
【问题讨论】:
标签: angular