0

Can we dynamically build attribute name on run time in the lightning component?

Use case-

<aura:iteration items="{!v.attributeA}" var="key">
    {!v.attributeB + "!key" + .length}
</aura:iteration>

So I am trying to use aura:iteration to loop through a list of string and within loop reference another attribute (type map). This map name has to use 'AttributeA : key' to form the correct name and then print the length of that map for that key.

Example,

AttributeA - "A, B"

AttributeB - "{OptionA : [item1, item2], OptionB : [item2, item3, item4]}"

Now, when looping through AttributeA, I need to reference AttributeB ("Option" + "A") to get number of items for OptionA (2 items), OptionB (3 items) etc.

1 Answer 1

1

No, LC does not allow this. Instead, you would need to build a List for aura:iteration to work with. You can handle this transformation of data in an aura:valueChange or aura:valueInit handler, as appropriate.

0

You must log in to answer this question.

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