I have map attribute in lightning component. It has id key and value is true or false for checkbox.
<aura:attribute name="customMap" type="Map" />
I want to iterate via array and get value from this map (that is already populated).
<aura:iteration items="{! v.customList }" var="customListItem">
<lightning:input aura:id="{! customListItem.Id }" type="checkbox" label=" " onchange="{! c.checkCustomMap }" checked="SET_CHECKED_OR_ONCHECKED"/>
</aura:iteration>
Best Answer
You can workaround with two more steps:
The Component:
Matching the Map key with the custom list usong
aura:if
. If key matched then print the checkbox with the value that Map contains. It can befalse
ortrue
. It will show checkbox for the keys present in Map only.The controller:-
Here I converted the
Map
into object list accessible in the component.Note: If Map has checkbox value as String, it will check all checkbox regardless of value (true/false). So, it required to be converted in Boolean type for correct re-rendering.