I want to set the incremented value to lightning input when a button is pressed. In aura iteration n number of record when I click on a button it is copying the value to all lightning input. But in my case, I would like to set value only to the current input. I am getting the index but I am not able to set the value.
component :
<aura:component >
<aura:attribute name="quantity" type="String" default="0"/>
<aura:attribute name="itemList" type="List" default="[1,2,3]"/>
<aura:iteration items="{!v.itemList}" var="prod" indexVar="index">
<div data-index="{!index}" style="display:flex">
<lightning:input value="{!v.quantity}" name="{!'itemQuantity_'+ index}" aura:id="itemInput"/>
<lightning:button label="Add" onclick="{!c.addValue}" name="{!'itemQuantity_'+ index}"/>
</div>
</aura:iteration>
</aura:component>
Controller :
addValue : function(component, event, helper) {
var selindex = event.target.dataset.index;
var count = component.get("v.quantity");
count++;
component.set("v.quantity", count);
}