[SalesForce] Lightning: dynamic index in aura attribute with type List

related post

I am having the same issue. Trying to access array with dynamic index arrayList[index] (index from aura:iteration), but Salesforce doesn't support that.

Does anyone know how to do this?

Peace of code:

<aura:attribute name="iterList"             type="List" />
<aura:attribute name="phones"               type="String[]" />



<aura:iteration items="{! v.iterList }" var="val" indexVar="index">
    //some code here

            <ui:inputPhone label="{! v.labelName }" aura:id="phone" value="{! v.phones[index] }" class="form-control"/> 

   //some code here
</aura:iteration>

Error:

Result: [ERROR]: expecting a positive integer, found 'index' at column 11 of expression: v.phones[index]

Best Answer

I needed something similar so I used HTML input components instead of Ui:input components and used the data-selected-Index attribute for storing the index value

Related Topic