I have a requirement to pass parameter(indexVar of iteration) from lightning component to javascript controller.
<aura:iteration items="{!v.productListWrapper}" var="pro" indexVar="index">
<ui:inputSelect aura:id="selectedproductWrapper" class="select-options inline" change="{!c.priceListChange}" value="{!v.priceListValue}" >
<aura:iteration items="{!pro.productPriceList}" var="priceList">
<ui:inputSelectOption text="{!priceList.value}" label="{!priceList.label}"/>
</aura:iteration>
</ui:inputSelect>
I want to pass index to javascript controller when user select a value(pricelist) from input select option.
I am able to do this for anchor tag using data attribute but it's not working for input select.
<a onclick="{!c.changePricelist" data-index="{!index}" ><u>ChangePriceList</u></a><br/>
{!priceList.value}
you can pass thevarIndex
in the text ofinputSelectOption
, so you will have the selected var index in thepriceListValue
attribute. This is only if you don't need the text of it.