我希望生成动态表格,表头和行/列是根据来自 WebAPI 的 JSON 对象动态生成的。
这里是每次都不同的JSON对象示例。
所以我尝试过但无法实现带有标题和行/列的动态表格。
我的html代码如下:
[
{"Country":"Australia","Toner Quantity":8},
{"Country":"China","Toner Quantity":6},
{"Country":"India","Toner Quantity":11},
{"Country":"South Korea","Toner Quantity":1}
]
有时它会像这样出现
[
{"CustomerName":"FORD","Australia":0,"China":2,"India":0,"South Korea":0},
{"CustomerName":"ICICI PRUDENTIAL","Australia":0,"China":0,"India":5,"South Korea":0},
{"CustomerName":"Kimberly Clark","Australia":0,"China":0,"India":0,"South Korea":1},
{"CustomerName":"McDonalds","Australia":1,"China":0,"India":0,"South Korea":0},
{"CustomerName":"Novartis","Australia":1,"China":0,"India":0,"South Korea":0},
{"CustomerName":"Origin Energy","Australia":3,"China":0,"India":0,"South Korea":0}
]
所以我尝试过但无法实现带有标题和行/列的动态表格。
我的html代码如下:
<table class="table striped">
<thead>
<tr role="row">
<th ng-repeat="th in dataconfigureListData.previewData">{{th}}</th>
</tr>
</thead>
<tbody>
<tr role="row" data-ng-repeat="previewData in dataconfigureListData.previewData">
<td> {{previewData.Country}}</td>
<td> {{previewData['Total Toner Qty']}}</td>
</tr>
</tbody>
</table>