我有以下带有列和数据的对象。我想使用* ngFor显示列值。
到目前为止,我已经尝试了以下代码:
public productLists;
this.productLists = [];
this.productLists = this.loadProductLists();
<tr *ngFor="let column of productLists.columns">
<th scope="col">{{column}}</th>
</tr>
columns:
action: "Action"
product_code_clip: "Product Code Clip"
product_name_clip: "Product Name Clip"
year: "Year"
__proto__: Object
data: (15) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
答案 0 :(得分:0)
您是否尝试过对专栏对象中的数据数组进行迭代?
<tr *ngFor="let column of productLists.columns.data">
<th scope="col">{{column}}</th>
</tr>