I have an auraif when I tried to use the condition And (&&) it points error:

<aura:if isTrue="{!v.value == 'test' && v.recTypeName == 'testing'}">


3 Answers 3


Try to use the and expression function, as in:

<aura:if isTrue="{! and(equals(v.value, 'test'), equals(v.recTypeName, 'testing')) }">


  • This does not work either Commented Jun 14, 2019 at 15:46
  • Thank you so much I had tried in a very similar way. But without success kk
    – Barbilque
    Commented Jun 14, 2019 at 15:47
  • Please update your original question with the error message, and make sure that both values you are using in the condition are set. Commented Jun 14, 2019 at 15:48
  • I've edited my answer to use the equal function as well. If it still throws you an error, it is likely a problem outside this expression. Commented Jun 14, 2019 at 15:49

Assuming that you are trying to use && and getting error, then that's expected. Using && is not allowed in components. You will need to use &amp;&amp; in that case.

However, it is recommended that you use and(condition). This is from the documentation:

&amp;&amp; This syntax is awkward in markup so we recommend using the and function instead.


You can do your calculations in a javascript controller and write the result to an aura attribute

Component Markup

    <!-- Attributes -->
    <aura:attribute name="value" type="String"/>
    <aura:attribute name="recTypeName" type="String"/>
    <aura:attribute name="testValue" type="Boolean"/>
    <aura:attribute name="testRecType" type="Boolean"/>

    <!-- Initialize event to handle calculating the boolean values-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

JS Controller

    doInit : function(component, event, helper) {
        component.set('v.testValue', (component.get('v.value') == 'test'));
        //similar syntax for the recTypeName

Then your initializer will run every time the component begins. Or you can code a similar calculation in some other function for more frequent updates

You can use the aura:if and isTrue attribute as follows:

<aura:if isTrue="{!and(v.testValue, v.testRecType)}">

  • The operators do work in aura expressions, though.
    – sfdcfox
    Commented Jun 14, 2019 at 16:31
  • Thanks, edited. Commented Jun 14, 2019 at 16:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .