0

I want to iterate over List<Map<String, Object>>. I'm not sure how to do it. Below is the response I am getting from apex class to aura controller.

[{"label":"Test 1","name:"Test Value},{"label":"Test 2","name":"Test Value"},{"label":"Test 3","name":"Test Value"}].

Below is the code I tried.

JS Side:

var custs = [];
var conts = response.getReturnValue(); //List<Map<String, Object>>
for ( var key in conts) {
    custs.push({value:conts[key], key:key});
}
component.set("v.totalResult", custs);

HTML Side :

<aura:attribute name= "totalResult" type="List" />

Can anyone let me know how to resolve this.

1 Answer 1

0

Use aura:iteration to iterate over a list

<aura:iteration items="{!v.totalResult}" var="item">
 <p>Name : {!item.name}</p>
 <p>Label: {!item.label}</p>
</aura:iteration>
1
  • My bad !! Thanks a lot !! By seeing the Map inside the List, I got confused. It works now
    – sfdcOwl
    Commented May 18, 2022 at 7:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .