【发布时间】:2018-07-19 20:31:42
【问题描述】:
我有一个这样的 json 数组。
[
{
"variations": {
"title": {
"newValue": "test new value1",
"oldValue": "test old value1"
}
}
},
{
"variations": {
"data": {
"newValue": "new data",
"oldValue": "httpold data"
},
"length": {
"newValue": "48",
"oldValue": "9.00"
}
}
}
]
从这里我想获得 Html 中变化的长度,以及要查看的渲染和值。
<table class="table table-bordered table-hover">
<thead class="table-title">
<tr>
<th class="text-center">Field count</th>
<th class="text-center">Field Name</th>
<th class="text-center">Old Value</th>
<th class="text-center">New Value</th>
</tr>
</thead>
<tbody *ngFor="let data of datas">
<tr>
<td class="text-left" rowspan="2">{{data.variations.length}}</td>
<td class="text-left" rowspan="2"></td>
<td class="text-left" rowspan="2"></td>
</tr>
<tr>
</tr>
</tbody>
</table>
在上面的代码中,我如何获得length 的variation 数据。还需要将所有新字段和旧字段值渲染并显示到视图中。
谁能帮帮我
【问题讨论】:
-
使用
data['variations'].length -
它显示如下 [object Object]
标签: html json angular angular2-template