0

I've two objects:

listContent: [{'Id':1,'Name':'SF'},{'Id':2,'Name':'DS'}]
fields:['Id','Name']

Now I'm using nested aura iteration to display the listContent as shown below:

<aura:iteration items="{!v.listContent}" var="s">
    <aura:iteration items="{!v.fields}" var="i">
        <p>{!(s[i])}</p>
    </aura:iteration>
</aura:iteration>

I'm not able to display values of the fields coming from inner loop from object coming from outer loop. Kindly help, how to combine them both.

0

What you're trying to do isn't allowed in Aura. Instead, you need to convert your data into a an Array of Arrays.

var output = listContent.map(
  row => fields.map(
    field => row[field]
  )
);

Which you would then iterate over each row, and in each row, you'd iterate over each element.

<aura:iteration items="{!v.output}" var="row">
    <aura:iteration items="{!row}" var="field">
        <p>{!field}</p>
    </aura:iteration>
</aura:iteration>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.