Is it possible to iterate over a map in Lightning

Is it possible to iterate over a Map in an aura:iteration. It doesn’t give me a compile or runtime error but it doesn’t appear to work.

My thought is that it works similarly to $.each in jquery.

<aura:attribute type="Map" name="myMap"  default="{key1: 'item1', key2: 'item2'}" />       
<aura:iteration items="{!myMap}" indexVar="key" var="item">
      {!key} : {!item} 


According to the Aura docs it looks like this is only defined to iterate over a List.

If you have not seen the Aura docs app before it is available with any Salesforce instance by modifying the URL:

[your instance stuff]

Or to navigate to the page for the iteration component:

[your instance stuff]

Source : Link , Question Author : Scott Morrison , Answer Author : Kalin

Leave a Comment