1

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>
  • 1
    i think you missed ! HERE {!add(v.flag,1)} – Ratan Paul Apr 27 '17 at 5:59
  • But i am not getting that error due to that i think.The error here means something different – Deepak Agarwal Apr 27 '17 at 6:07
  • Try this type="Integer" instead on type="integer" as we all know JS is case sensitive. This might be an issue. – itzmukeshy7 Apr 27 '17 at 6:28
  • Have tried Ratan's fix and have confirmed that it does not solve the problem? – Keith C Apr 27 '17 at 7:08
  • No that didnt work.How ever my issue is resolved i found the other way around without using <aura:set>.Thanks anyways' – Deepak Agarwal Apr 27 '17 at 9:08
2

aura:set doesn't work like this.

From the doc:

When you include another component, such as , in a component, we call that a component reference to . You can use to set an attribute on the component reference.

aura:set when used inside a parent element, it sets the value of the attribute of the parent element. Here, your parent element is aura:iteration, so its searching for an attribute on aura:iteration which is obviously not present.

The error you are getting is explaining the same:

Failed to save undefined: The attribute "flag" was not found on the COMPONENT markup://aura:iteration: Source

  • I tried to declare aura:set inside aura:iteration then also i am getting same error. – Deepak Agarwal May 4 '17 at 10:54
  • 2
    So what will be the otherway around this. – Deepak Agarwal May 4 '17 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.