Avoiding nested aura:if in aura:iteration

To understand this scenario, let's take an example component code. Let's name the component ifElseLadder. The component displays numbers in a nested manner.

The component code is as follows:

<aura:component >    <aura:attribute name="truthy" type="Boolean" default="false"/>    <aura:attribute name="innerCmpDisplay" type="Boolean" default="true"/>    <aura:attribute name="arraySize" type="List" default="[]"/>    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>    <aura:iteration items="1,2,3,4,5" var="item">    <aura:if isTrue="{!v.truthy}">        True         <aura:set attribute="else">          <aura:iteration items="{!v.arraySize}" var="i">            <aura:if isTrue="{!v.innerCmpDisplay}">                <div>                    {!i}                </div> <aura:iteration items="{!v.arraySize}" ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.