1

I am not sure why this is not working. I have an aura:if condition, if the check matches then the item should be displayed. Here in this code below I am checking the ofc.agentName is not empty then the item should be shown. Plz advise!

<aura:if isTrue="{! notequals(ofc.agentName, ' ')}">
   <li class="slds-p-left_xx-small slds-p-left_xxx-small">{! ofc.agentName }<Strong><i >Name Not Matched</i></Strong></li>
</aura:if>

1 Answer 1

3

notequals(ofc.agentName, ' ') compares the value to a single space character, ' '. To check if the value is empty, use the empty() function:

!empty(ofc.agentName)

This will evaluate to true if the value is anything other than undefined, null, the empty array, and the empty string. (Note that it doesn't check for strings composed only of whitespace, though).

5
  • 1
    +1,Propably !!empty(ofc.agentName) for negation! Commented Dec 19, 2018 at 21:49
  • 1
    Well, "{! !empty() }"
    – David Reed
    Commented Dec 19, 2018 at 21:50
  • Agreed! OP was looking for negation so, just saying. Thanks Commented Dec 19, 2018 at 21:51
  • Right but I think one ! is the use case here, no? He wants "not equal to blank" => !empty()
    – David Reed
    Commented Dec 19, 2018 at 21:52
  • Or am I looking at it sideways again?
    – David Reed
    Commented Dec 19, 2018 at 21:52

You must log in to answer this question.

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