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?

9

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))}">

| improve this answer | |
  • 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 Jan 23 '19 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 Jan 23 '19 at 14:21
  • 1
    @JohnTowers +1 for the sharing this, a new learning today. Everyday is a new day in Salesforce. – Jayant Das Jan 23 '19 at 14:25
  • 5
    Seems far preferable to just use and. – Adrian Larson Jan 23 '19 at 16:37
  • 1
    Brought this to Salesforce Docs' attention, and they have acknowledged it to be included in the docs. – Jayant Das Jan 23 '19 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.