7

According to this reference the syntax below:

<aura:if isTrue="{!and(v.isVisible,!empty(v.subjectsList))}">

should be equivalent to:

<aura:if isTrue="{!v.isVisible && !empty(v.subjectsList)}">

However, I receive the message below when I try to save the lightning component to the sandbox:

FIELD_INTEGRITY_EXCEPTION - c:SubjectSelectionView_GCC:69,34: ParseError at [row,col]:[70,34]
Message: The entity name must immediately follow the '&' in the entity reference.: Source

So, What am I missing?

1

1 Answer 1

10

Instead of && you can use &amp;&amp; (the HTML entity for &). That seems to satisfy the parser and the expression will still execute your logic correctly.

So your code will be:

<aura:if isTrue="{!v.isVisible &amp;&amp; !empty(v.subjectsList)}">

Edit

As noted in the comments, it's probably better to use and like:

<aura:if isTrue="{!and(v.isVisible, !empty(v.subjectsList))}">

7
  • 5
    @JayantDas No, Lightning requires it. It is not specific to the Developer Console. Go ahead and try it out in your favorite IDE. ... It's technically an oversight in the documentation, as far as I can tell. Aura has always worked this way.
    – sfdcfox
    Commented Jan 23, 2019 at 14:17
  • 1
    AND function is more readable in case we have 2 parameters: <aura:if isTrue="{!and(v.isVisible, !empty(v.subjectsList))}">
    – Raul
    Commented Jan 23, 2019 at 14:21
  • 1
    @JohnTowers +1 for the sharing this, a new learning today. Everyday is a new day in Salesforce.
    – Jayant Das
    Commented Jan 23, 2019 at 14:25
  • 5
    Seems far preferable to just use and.
    – Adrian Larson
    Commented Jan 23, 2019 at 16:37
  • 1
    Brought this to Salesforce Docs' attention, and they have acknowledged it to be included in the docs.
    – Jayant Das
    Commented Jan 23, 2019 at 20:17

You must log in to answer this question.

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