Newer Version Available
Conditional Expressions
Here are examples of conditional expressions using the ternary operator and the
<aura:if> tag.
Ternary Operator
This expression uses the ternary operator to conditionally output one of two values dependent on a condition.
The {!v.location == '/active' ? 'selected' : ''} expression conditionally sets the class attribute of an HTML <a> tag, by checking whether the location attribute is set to /active. If true, the expression sets class to selected.
Using <aura:if> for Conditional Markup
This snippet of markup uses the <aura:if> tag to conditionally display an edit button.
If the edit attribute is set to true, lightning:button displays. Otherwise, the text in the else attribute displays.