Search code examples
angularjsangularjs-ng-repeat

how get the "parent name" and read the object in the ng-repeat AngujarJs?


if i have a response object like this:

Object Json format from my js file and i need use the ng-repeat for this element but i need to get the name "street 1" too, how can use the ng-repeat for get all values with the "parent name" and his properties. Thanks


Solution

  • try something like this

    <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>
    

    or

    <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>