Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Aura if - isTrue parameter and multiple conditions

Asked by Yamamoto Saito Aug 5, 2021 4.7K views 2 answers
Share

About this question


Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on Jun 14, 2024

In Salesforce's Aura components, the aura:if component is used to conditionally render content based on an expression. The isTrue attribute of aura:if accepts a boolean expression to determine whether the content inside should be rendered.

To handle multiple conditions, you can use logical operators (&& for AND, || for OR) within the isTrue parameter. Here’s how you can do it:

Using aura:if with Multiple Conditions

Example with AND Condition (&&)


Example with OR Condition (||)


Handling More Complex Conditions

You can also combine multiple conditions with both AND and OR logical operators. Make sure to use parentheses to group conditions correctly and ensure the logical operations are evaluated in the desired order.

Example with Complex Conditions


Practical Example

Here's a practical example that combines these concepts into a single Aura component.

Summary

  • Use && to combine conditions with a logical AND.
  • Use || to combine conditions with a logical OR.
  • Use parentheses () to group conditions and control the order of evaluation.
  • Use aura:set with the else attribute to render alternative content when the condition is false.

These examples should help you implement complex conditional rendering in your Aura components using the aura:if component.

Was this helpful?

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.