0

I have an object(parent) with multiple objects(current) inside it. I use ng-repeat to display all the (current)objects. These current object has a unique name.

What I want to do is get the unique name and display it to inside the view.

This is what's inside the object(parent) when I use console.log

5b6055ad59040d3624c81c114d04aa2a: Object
    addons: Array[5]
    data: Object
8c56c8cbe6d415ba4d036d8dc859683: Object
    addons: Array[5]
    data: Object
c8f22c12b7aaf10fe360f438e0931a4d: Object
    addons: Array[5]
    data: Object

This is the view of the angular code. So I want for example "5b6055ad59040d3624c81c114d04aa2a" to show inside the h3 tags.

<div class="product" ng-repeat="item in cart.items">
    <ul>
        <li><h3>{{item.uniquename}}</h3></li>
        <li>
            <span class="left">Name:</span>
            <span class="right">{{item.addons[0].value}}</span>
        </li>
    </ul>
</div>
Raymond the Developer
  • 1,576
  • 5
  • 26
  • 57

1 Answers1

1

If by uniquename you refer to the key of each of the items in your array, you can iterate as key/value as follows:

<div class="product" ng-repeat="(uniquename, item) in cart.items">
    <ul>
        <li><h3>{{uniquename}}</h3></li>
        <li>
            <span class="left">Name:</span>
            <span class="right">{{item.addons[0].value}}</span>
        </li>
    </ul>
</div>
taxicala
  • 21,408
  • 7
  • 37
  • 66