Search code examples
angularjsangularjs-ng-repeatkey-value

How do you ng-repeat through an object of objects to show key and value?


I have an object called "profile" that includes a handful of other objects -- each one I want to display the label followed by the display_value:

enter image description here

In my HTML, I know I need to ng-repeat through the object profile, but have not been able to get the desired display of label: display_value (i.e. Employment Start Date: 11/20/2019). What is the correct syntax to loop through c.profile and display label followed by display_value? Do I need two ng-repeats in this instance?

<div ng-repeat="item in c.profile track by $index">
  {{item.?}}:  {{item.?}}
</div>

Solution

  • <div ng-repeat="item in c.profile track by $index">
      {{item.label}}:  {{item.display_value}}
    </div>
    

    make sure your data is what you expect it to be.