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
pandi GSpandi GS 

The aura:if not validating the INDEX inside the Aura:iteration issue

HI, 
I am iterating the list and i want to display in the columns.  i am checking the index inside the iteration, and when i compare in aura if, it is not working. The check always goes to ELSE part only. What mistake i'm doing? please help
<aura:attribute name="ALCDMLst" type="List" default="[
     {'label': 'All Adults', 'value': 'AllAdult','Child':[]},
    {'label': 'Lifestyle Topics', 'value': 'option1','Child':[{'label':'Unhealthy Diet','value':'UD'},{'label':'Inadequate Exercise','value':'IE'},{'label':'Stress','value':'ST'}]},
    {'label': 'Heart and Blood Vessel Conditions', 'value': 'option2','Child':[{'label':'Blood Clot','value':'BC'},{'label':'Heart Failiure','value':'HF'},{'label':'Stroke','value':'SK'}]},
	{'label': 'Diabetes', 'value': 'option3','Child':[]},
    {'label': 'Lung Condition', 'value': 'option4','Child':[{'label':'Asthma','value':'AS'},{'label':'COPD','value':'CPD'}]},
	{'label': 'Stomach and Intenstine Conditions', 'value': 'option5','Child':[{'label':'Chronic hepatitis B or C','value':'hipa'},{'label':'Stomach Ulcer','value':'SCU'}]},
	{'label': 'Cancer', 'value': 'option6','Child':[{'label':'Colon','value':'CN'},{'label':'Lung','value':'LG'}]}
    ]"/>

<aura:iteration var="oppz" items="{!v.ALCDMLst}" indexVar="indexs">
                  
<aura:if istrue="{!lessthan(indexs , 3)}">
True
<aura:set attribute="else">
False
</aura:set>
</aura:if>

 
Raj VakatiRaj Vakati
Use this code

 
<aura:iteration var="oppz" items="{!v.ALCDMLst}" indexVar="indexs">
        <aura:if isTrue="{!indexs &gt; 2}"> 
            True
            <aura:set attribute="else">
                False
                
            </aura:set>
        </aura:if>
        
        
    </aura:iteration>

User-added image

Complete code 


 
<aura:component >
    <aura:attribute name="ALCDMLst" type="List" default="[
                                                         {'label': 'All Adults', 'value': 'AllAdult','Child':[]},
                                                         {'label': 'Lifestyle Topics', 'value': 'option1','Child':[{'label':'Unhealthy Diet','value':'UD'},{'label':'Inadequate Exercise','value':'IE'},{'label':'Stress','value':'ST'}]},
                                                         {'label': 'Heart and Blood Vessel Conditions', 'value': 'option2','Child':[{'label':'Blood Clot','value':'BC'},{'label':'Heart Failiure','value':'HF'},{'label':'Stroke','value':'SK'}]},
                                                         {'label': 'Diabetes', 'value': 'option3','Child':[]},
                                                         {'label': 'Lung Condition', 'value': 'option4','Child':[{'label':'Asthma','value':'AS'},{'label':'COPD','value':'CPD'}]},
                                                         {'label': 'Stomach and Intenstine Conditions', 'value': 'option5','Child':[{'label':'Chronic hepatitis B or C','value':'hipa'},{'label':'Stomach Ulcer','value':'SCU'}]},
                                                         {'label': 'Cancer', 'value': 'option6','Child':[{'label':'Colon','value':'CN'},{'label':'Lung','value':'LG'}]}
                                                         ]"/>
    
    <aura:iteration var="oppz" items="{!v.ALCDMLst}" indexVar="indexs">
        <aura:if isTrue="{!indexs &gt; 2}"> 
            True
            <aura:set attribute="else">
                False
                
            </aura:set>
        </aura:if>
        
        
    </aura:iteration>
</aura:component>

 
Raj VakatiRaj Vakati
Use this
<aura:component >
    <aura:attribute name="ALCDMLst" type="List" default="[
                                                         {'label': 'All Adults', 'value': 'AllAdult','Child':[]},
                                                         {'label': 'Lifestyle Topics', 'value': 'option1','Child':[{'label':'Unhealthy Diet','value':'UD'},{'label':'Inadequate Exercise','value':'IE'},{'label':'Stress','value':'ST'}]},
                                                         {'label': 'Heart and Blood Vessel Conditions', 'value': 'option2','Child':[{'label':'Blood Clot','value':'BC'},{'label':'Heart Failiure','value':'HF'},{'label':'Stroke','value':'SK'}]},
                                                         {'label': 'Diabetes', 'value': 'option3','Child':[]},
                                                         {'label': 'Lung Condition', 'value': 'option4','Child':[{'label':'Asthma','value':'AS'},{'label':'COPD','value':'CPD'}]},
                                                         {'label': 'Stomach and Intenstine Conditions', 'value': 'option5','Child':[{'label':'Chronic hepatitis B or C','value':'hipa'},{'label':'Stomach Ulcer','value':'SCU'}]},
                                                         {'label': 'Cancer', 'value': 'option6','Child':[{'label':'Colon','value':'CN'},{'label':'Lung','value':'LG'}]}
                                                         ]"/>
    
    <aura:iteration var="oppz" items="{!v.ALCDMLst}" indexVar="indexs">
        <aura:if isTrue="{!indexs &gt; 3}"> 
            True
            <aura:set attribute="else">
                False
                
            </aura:set>
        </aura:if>
        
        
    </aura:iteration>
</aura:component>