我有来自我的节点rest的以下输出:
{
"workorder": [
{
"id": 1,
"Workorderno": 110,
"Nfno": 23,
"Amount": 230,
"Orderno": 34,
"createdAt": "2019-03-02 00:19:49.495 +00:00",
"updatedAt": "2019-03-02 12:40:36.647 +00:00"
}
]
}我想使用角7读取输出并将其显示在表中?有人能指导我做那件事吗?我试着修改rest,但是失败了,我可以得到结果。
发布于 2019-03-04 01:30:59
您需要这样的东西使用ngFor,
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Workorder No</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let work of data.workorder">
<td>{{work?.id}}</td>
<td>{{work?.Workorderno}}</a></td>
</tr>
</tbody>
</table>
</div>你的界面应该是这样,
export interface Workorder {
id: number;
Workorderno: number;
Nfno: number;
Amount: number;
Orderno: number;
createdAt: string;
updatedAt: string;
}然后在你的身体里,
data : Workorder;
constructor(private service: nowService) {
}
ngOnInit() {
this.service.getAll().subscribe((data) => {
this.data = data;
})
}
}发布于 2019-03-04 06:54:19
尝试添加到tr标记: ngIf="data.workorder!=null“
https://stackoverflow.com/questions/54975509
复制相似问题