I am trying to set the value of aura attribute
in aura iteration
.I am declaring
<aura:attribute name="flag" type="integer" default="0"/>
And in <aura:iteraton>
i am trying to set this flag value but i am unable to do it due to following error:
Failed to save undefined: The attribute "flag" was not found on the COMPONENT markup://aura:iteration: Source
And i am setting the value like following:
<aura:attribute name="flag" value="0" type="integer"/>
<aura:iteration>
<!-- some condition goes here to set the value-->
<aura:set attribute="flag" value="{add(v.flag,1)}"/>
</aura:iteration>
Best Answer
aura:set
doesn't work like this.From the doc:
aura:set
when used inside a parent element, it sets the value of the attribute of the parent element. Here, your parent element isaura:iteration
, so its searching for an attribute onaura:iteration
which is obviously not present.The error you are getting is explaining the same: