我是angularjs的新手,我有一个网状json,需要带到一张桌子中。
$scope.contacts = [
{
"u_cmdb_ci_service_said":{
"display_value":"ZISAPP02025",
"label":"SAID",
"type":"string",
"value":"ZISAPP02025"
},
"sys_id":"df7dfab4db3a43c0fa01323b7c96191a",
"targetTable":"cmdb_ci_service",
"u_cmdb_ci_service_application_code":{
"display_value":"ZIS",
"label":"Application code",
"type":"string",
"value":"ZIS"
},
"name":{
"display_value":"CENTRALISED STRUCTURE INFORMATION SYSTEM (CENSIS)",
"label":"Name",
"type":"string",
"value":"CENTRALISED STRUCTURE INFORMATION SYSTEM (CENSIS)"
},
"owned_by":{
"display_value":"",
"label":"Owned by",
"type":"reference",
"value":""
},
"u_cmdb_ci_service_crown_jewels":{
"display_value":"false",
"label":"Crown jewels",
"type":"boolean",
"value":"false"
},
"u_cmdb_business_owner":{
"display_value":"Steven Furjanic [SSC]",
"label":"Business owner",
"type":"reference",
"value":"0a4167c1dbd20700047dd7795e9619f7"
}
}
]
我想将所有label
显示为标题,并将display_value
显示为这些标题的值。谁能帮我做到吗?
附上我尝试过的小提琴。
[Note :duplicates should be restricted based on 'SAID, display_value'
。我尝试使用unique
过滤器无法正常工作。
如下更改您的HTML代码:
<table class="table table-striped">
<tr ng-repeat="v in contacts">
<td>
<table>
<tr>
<th ng-repeat='o in v'>{{o.label}}</th>
</tr>
<tr>
<td ng-repeat='o in v'>{{o.display_value}}</td>
</tr>
</table>
</td>
</tr>
</table>
这里更新了小提琴:http://jsfiddle.net/kmj70b8t/3/
进一步要删除重复项,请创建AngularJs filter