Newer Version Available
aura:if
aura:if renders the
content within the tag if the isTrue attribute evaluates to true.
The framework evaluates the isTrue expression and instantiates components either in its body or else attribute.
| Attribute Name | Type | Description |
|---|---|---|
| else | ComponentDefRef[] | The markup to render when isTrue evaluates to false. Set this attribute using the aura:set tag. |
| isTrue | string | Required. An expression that determines whether the content is displayed. If it evaluates to true, the content is displayed. |
Example
This snippet of markup uses the <aura:if> tag to conditionally display an edit button.
1<aura:attribute name="edit" type="Boolean" default="true"/>
2<aura:if isTrue="{!v.edit}">
3 <ui:button label="Edit"/>
4 <aura:set attribute="else">
5 You can’t edit this.
6 </aura:set>
7</aura:if>If the edit attribute is set to true, a ui:button displays. Otherwise, the text in the else attribute displays.