function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alexander HadjiiordanovAlexander Hadjiiordanov 

simple iteration problem

Hi all,

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

 
Best Answer chosen by Alexander Hadjiiordanov
Maharajan CMaharajan C
Hi Alexander,

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

Maharajan CMaharajan C
Hi Alexander,

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
This was selected as the best answer
Alexander HadjiiordanovAlexander Hadjiiordanov
worked like a charm :)
thanks Maharajan
best answer marked but don't know how to mark the thread as solved