I'm trying to loop through a JSON object using ng-repeat
, using this as reference. What I currently have is:
<mat-card-content>
<p>{{ selected.items }}</p>
<p>{{ selected.items["0aa60412-a62b-4967-8c9e-b12764df6a9d"].itemName }}</p>
<ul>
<li ng-repeat="item in selected.items">{{ item.itemName }}</li>
</ul>
</mat-card-content>
where the 2nd <p>
uses a hardcoded ID of the first entry being returned
The <p>
tags work, but the <li>
does not, it just has a single bullet with no content in it (where the object has 16 items). The console gives the error TypeError: Cannot read property 'itemName' of undefined
.
The JSON object is formatted like so:
{
"0aa60412-a62b-4967-8c9e-b12764df6a9d": { itemName: "value", [...] },
[...]
}
Other attempts which also failed include:
<li ng-repeat="(key, value) in selected.items">{{ key }}</li>
What am I doing wrong here?