How to use ng-repeat to iterate over map entries in AngularJS

Angularjs

Angularjs Problem Overview


How would you iterate over the entries in map such that both the entry key and the value can be printed? For example, I'd like to do something like this:

<ul>
    <li ng-repeat='mapEntry in {"First Name":"John", "Last Name":"Smith"}'>
        <span>Key: {{mapEntry.key}}, value: {{mapEntry.value}}</span>
    </li>
</ul>

Angularjs Solutions


Solution 1 - Angularjs

From the docs, I found this syntax works:

<ul>
    <li ng-repeat='(key, value) in {"First Name":"John", "Last Name":"Smith"}'>
        <span>Key: {{key}}, value: {{value}}</span>
    </li>
</ul>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex SpurlingView Question on Stackoverflow
Solution 1 - AngularjsAlex SpurlingView Answer on Stackoverflow