Nested AURA:IFs in Lightning Components Salesforce
You can use use the nested IFs on the framework.
Go to Developer Console>>New>>Lightning Application
Give it a name, Submit
Here is a sample code:
One important thing to notice here is you can not leave the else empty,
It CANNOT be :
<aura:if isTrue="{!item=='4'}">
<b>In The Fourth IF </b> <br/>
<aura:set attribute="else">
</aura:set>
</aura:if>
I have left it empty, it lets you save, but gives you runtime error.
either remove it completely or just keep some value.
HTH,
Prabhan
Go to Developer Console>>New>>Lightning Application
Give it a name, Submit
Here is a sample code:
<aura:application >
<aura:iteration items="1,2,3,4,5" var="item">
Iteration {!item} -
<aura:if isTrue="{!item=='1'}">
<b>In The First IF </b> <br/>
<aura:set attribute="else">
<aura:if isTrue="{!item=='2'}">
<b>In The Second IF </b> <br/>
<aura:set attribute="else">
<aura:if isTrue="{!item=='3'}">
<b>In The Third IF </b> <br/>
<aura:set attribute="else">
<aura:if isTrue="{!item=='4'}">
<b>In The Fourth IF </b> <br/>
<aura:set attribute="else">
In The Else of Last IF (Not 1 2 3 4) <br/>... And so you can use nested aura:ifs..
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:iteration>
</aura:application>
Output:<aura:iteration items="1,2,3,4,5" var="item">
Iteration {!item} -
<aura:if isTrue="{!item=='1'}">
<b>In The First IF </b> <br/>
<aura:set attribute="else">
<aura:if isTrue="{!item=='2'}">
<b>In The Second IF </b> <br/>
<aura:set attribute="else">
<aura:if isTrue="{!item=='3'}">
<b>In The Third IF </b> <br/>
<aura:set attribute="else">
<aura:if isTrue="{!item=='4'}">
<b>In The Fourth IF </b> <br/>
<aura:set attribute="else">
In The Else of Last IF (Not 1 2 3 4) <br/>... And so you can use nested aura:ifs..
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:set>
</aura:if>
</aura:iteration>
</aura:application>
One important thing to notice here is you can not leave the else empty,
It CANNOT be :
<aura:if isTrue="{!item=='4'}">
<b>In The Fourth IF </b> <br/>
<aura:set attribute="else">
</aura:set>
</aura:if>
I have left it empty, it lets you save, but gives you runtime error.
either remove it completely or just keep some value.
HTH,
Prabhan
Nested Aura:Ifs In Lightning Components Salesforce >>>>> Download Now
ReplyDelete>>>>> Download Full
Nested Aura:Ifs In Lightning Components Salesforce >>>>> Download LINK
>>>>> Download Now
Nested Aura:Ifs In Lightning Components Salesforce >>>>> Download Full
>>>>> Download LINK 8i