You need to sign in to do that
Don't have an account?
Alexander Hadjiiordanov
simple iteration problem
Hi all,
the following code is working:
tried same thing with iteration but it is not working:
What am i missing?
Thanks
the following code is working:
<aura:if isTrue="{!v.AssPage > 5}"> <lightning:button label="{!v.AssPage - 5}" name="ButtonBack5" onclick="{!c.clickedButton}"/> </aura:if> <aura:if isTrue="{!v.AssPage > 4}"> <lightning:button label="{!v.AssPage - 4}" name="ButtonBack4" onclick="{!c.clickedButton}"/> </aura:if> <aura:if isTrue="{!v.AssPage > 3}"> <lightning:button label="{!v.AssPage - 3}" name="ButtonBack3" onclick="{!c.clickedButton}"/> </aura:if> <aura:if isTrue="{!v.AssPage > 2}"> <lightning:button label="{!v.AssPage - 2}" name="ButtonBack2" onclick="{!c.clickedButton}"/> </aura:if> <aura:if isTrue="{!v.AssPage > 1}"> <lightning:button label="{!v.AssPage - 1}" name="ButtonBack1" onclick="{!c.clickedButton}"/> </aura:if>
tried same thing with iteration but it is not working:
<aura:iteration items="[5,4,3,2,1]" var="item"> <aura:if isTrue="{!v.AssPage > !item}"> <lightning:button label="{!v.AssPage - !item}" name="{ButtonBack+!item}" onclick="{!c.clickedButton}"/> </aura:if> </aura:iteration>
What am i missing?
Thanks
Don't use the Exclamator infront of item in iteration.
i tried the below it's working fine.
<aura:attribute name="AssPage" type="Integer" default="3"/>
<aura:attribute name="ButtonName" type="String" default="ButtonBack"/>
<aura:iteration items="[5,4,3,2,1]" var="item">
<aura:if isTrue="{!v.AssPage > item}">
<lightning:button label="{!v.AssPage - item}" name="{!v.ButtonName + item}" onclick="{!c.clickedButton}"/>
</aura:if>
</aura:iteration>
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Maharajan.C
All Answers
Don't use the Exclamator infront of item in iteration.
i tried the below it's working fine.
<aura:attribute name="AssPage" type="Integer" default="3"/>
<aura:attribute name="ButtonName" type="String" default="ButtonBack"/>
<aura:iteration items="[5,4,3,2,1]" var="item">
<aura:if isTrue="{!v.AssPage > item}">
<lightning:button label="{!v.AssPage - item}" name="{!v.ButtonName + item}" onclick="{!c.clickedButton}"/>
</aura:if>
</aura:iteration>
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Maharajan.C
thanks Maharajan
best answer marked but don't know how to mark the thread as solved