【发布时间】:2021-11-24 18:57:31
【问题描述】:
我必须处理一个 JSON 文件。
在 JSON BOCAGES -> BLOCAGE > 我必须检索 QTE 和 DTE。
这是我的文件 JSON here
我的问题是,我显示QTE 和DTE 一次。
现在,我有这个 => enter image description here
我想得到这个结果 => enter image description here
我缺少数组元素 [1] 和 [2],如何从循环中添加它们?
这是我的方法prepareDataForBlocage()
prepareDataForBlocage(response) {
this.spinners.blockDetails = false;
if (response['RETURNCODE'] == "OKK00") {
let [variable1] = response['BLOCAGES']['BLOCAGE'];
this.statusLine = {
quantity: variable1['QTE'],
update: variable1['DAT'],
};
}
}
我的 HTML
<table class="table table-striped">
<tr style="background-color: #f8f9fa; font-weight: bold;">
<td style="width: 13%;">Quantity</td>
<td style="width: 13%;">Reason</td>
<td style="width: 13%;">Date</td>
<td style="width: 13%;">Référence</td>
</tr>
<tr *ngIf="statusLine.quantity != 0" >
<td>
{{statusLine.quantity | number:'1.2-2' }}
</td>
<td></td>
<td>
{{statusLine.update | dateddmmyyyy }}
</td>
<td>
</td>
</tr>
</table>
【问题讨论】:
-
使用行数组,而不是单个解构元素。
标签: javascript json angular typescript