【发布时间】:2017-05-13 11:55:26
【问题描述】:
这是我的 JSON 数组:
"user" : {
"id": 456,
"nickname": "xxx",
"pf": {
"id": 123,
"account": [
{
"accountid": 1494235749,
"status": "New",
"accountnbr": 12345,
"cyc": {
"cycid": 1494404053,
"active": true,
"status": "New",
"name": "QST192017",
},
},
{
"accountid": 1494403399,
"status": "New",
"accountnbr": 915177,
"cyc": {
"cycleid": 1494406299,
"active": true,
"status": "Closed",
"name": "QSL342014"
}
},
{
"accountid": 1494500399,
"status": "New",
"accountnbr": 90010,
}
]
},
}
这就是我的模板中的内容:
<tr *ngFor="let account of accounts">
<td>{{ account.accountnbr }}</td>
<td>{{ account.cyc.name}}</td>
</tr>
我试图检索我所有帐户的列表,并且您可以看到其中一个帐户没有 cyc,并显示错误,知道如何在列表中将缺少的 JSON 对象替换为 null 吗?
PS:我正在使用 angular2
谢谢。
/K
【问题讨论】:
-
我已经更新了我的问题:目的是显示所有帐户的列表。就是这样。