我有从静态网络服务调用中收到的对象数组。下面是从宁静的Web服务获取的数组的片段。
[{"id":1,"wt":1,"wtName":"WT1","ct":"CT1","dtType":"DT1"},{"id":2,"wt":2,"wtName":"WT2","ct":"CT2","dtType":"DT2"},{"id":3,"wt":3,"wtName":"WT3","ct":"CT3","dtType":"DT3"},{"id":4,"wt":4,"wtName":"WT4","ct":"CT4","dtType":"DT4"},{"id":5,"wt":5,"wtName":"WT5","ct":"CT5","dtType":"DT5"},{"id":6,"wt":6,"wtName":"WT6","ct":"CT6","dtType":"DT6"}]
我正在尝试遍历Angular-6 html文件中的此数组以形成表。下面是我用来遍历数组的代码片段:
案例-1
<tr *ngFor="let record of records">
<td>{{record[3]}}</td>
</tr>
什么也没打印,但是如果我执行以下操作,那么我看到记录即将来临:
案例-2
<tr *ngFor="let record of records">
<td>{{record.wtName}}</td>
</tr>
如果我可以使用索引而不是属性名称来打印上述数组中的元素,那么如果您可以指导我需要做的事情,这将非常有用。
非常感谢您的帮助。