如何获取“父名称”并在ng-repeat AngujarJs中读取对象?

时间:2019-02-28 23:35:39

标签: angularjs angularjs-ng-repeat

如果我有这样的响应对象:

Object Json format来自我的js文件,我需要为此元素使用ng-repeat,但是我也需要获得名称“ street 1”,如何使用ng-repeat来获取带有“父母的名字”和他的财产。谢谢

1 个答案:

答案 0 :(得分:0)

尝试这样的事情

<div ng-repeat = "(key ,value) in YourObject">
   <div class = "title">{{key}}</div> <!-- name of object e.g street1-->
   <div class = "body">contract : {{value[0].contract}} status: {{value[0].status}}</div>
   <div class = "body">contract : {{value[1].contract}} status: {{value[1].status}}</div>
</div>

<div ng-repeat = "(key ,value) in YourObject">
   <h1 class = "title">{{key}}</h1> <!-- name of object e.g street1-->
   <div class = "body" ng-repeat = "item in value">
        {{item.contract}} / {{item.status}} 
   </div>
</div>