3

I'm trying this code :

enter image description here

<!-- an exemple :
     isTrue='{!and(v.valueOneIsTrue, v.valueThreeIsTrue)}" >-->
<aura:if isTrue="{!AND((v._candidateDetails.contact.Nationalite__c != null), (v.editMode=='true'))}">
<!-- do something -->
</aura:if>

I'm having this issue : enter image description here

Is it possible to use the Aura:if this way, or is it the limit ? Is this (from here) the only way : enter image description here

Nb : rectify from screenshot --> editMode=='true'

1
  • 2
    Can you please edit your question to post a text version of the code? Also the screenshots here from other site is not too relevant here. If you need to callout, it will be good to just post the link here. As for your error, it seems you are trying to use editMode attribute without using it as v.editMode.
    – Jayant Das
    Feb 21, 2019 at 17:42

1 Answer 1

2

Compiler is complaining because you're using assignment (=) instead of conditional operator (==), in second condition: (editMode='true'). Also AND function is case sensitive.

Second problem mentioned by Jayant would give a problem at run time.

You need to change:

isTrue="{!AND(v._candidateDetails.contact.Nationalite__c != null), (editMode='true'))}"

to:

// not should if there is a typo as attribute _candidateDetails starts with an Underscore
isTrue="{!and(v._candidateDetails.contact.Nationalite__c != null), (v.editMode=='true'))}"

Can be more readable which is a matter of preference as:

isTrue="{!and(not(empty(v._candidateDetails.contact.Nationalite__c)), equals(v.editMode, 'true'))}"

Useful Reference: Expression Functions Reference in Lightning

3
  • Thanks, also one important thing I got wrong is the UpperCase : it does NOT work when tipping AND ! You have to use 'and'. Feb 22, 2019 at 13:35
  • Oh you're right, thats the curse of switching between case sensitive and insensitive languages.
    – Raul
    Feb 22, 2019 at 13:56
  • I agree, looks like nothing but I've lost minutes understanding where was my mistake there -after your help, again thanks Feb 22, 2019 at 14:13

You must log in to answer this question.

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