我对服务器的回答是这样的:
{
"message": " list received successfully",
"success": "true",
"data": {
"_list": [{
"id": "",
"name": "",
"image_url": null,
"is_occupation": true
},
{
"id": "",
"name": "",
"image_url": null,
"is_occupation": true
}
],
"responseCode":"",
}
如何在angular2中以列表(html)显示此数据?
答案 0 :(得分:0)
@Component({
selector:'list',
template: `
<table>
<thead>
<th>id</th>
<th>name</th>
<th>image_url</th>
<th>is_occupation</th>
</thead>
<tbody>
<tr *ngFor="let data of responseData.data._list">
<td>{{data.id}}</td>
<td>{{data.name}}</td>
<td>{{data.image_url}}</td>
<td>{{data.is_occupation}}</td>
</tr>
</tbody>
</table>`
})
export class List {
const responseData={
"message": " list received successfully",
"success": "true",
"data": {
"_list": [
{
"id": "",
"name": "",
"image_url": null,
"is_occupation": true
},
{
"id": "",
"name": "",
"image_url": null,
"is_occupation": true
}],
"responseCode":"",
};
}