Conditional Rendering in Lightning Component using aura:if in Salesforce

Conditional Rendering in Lightning Component using aura:if in Salesforce

Conditional rendering allows us to hide and show. 

We have to use 

1. aura:if

For showing contents when the condition is true.

2. aura:set

For showing contents when the condition is false.

Sample Lightning Aura Component:

<aura:component>
    <aura:attribute name="strTest" type="String"/>
    <aura:if isTrue="{!not(empty(v.strTest))}">
        True
        <aura:set attribute="else">
            False
        </aura:set>
    </aura:if> 
</aura:component>

Check the below link for more methods
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_functions.htm

Leave a Reply