9

How can I set a Lightning Component visibility based on text filed value = NULL. I have a text area field and I want to only display one component if Text area field contains value. I can't seem to be able to find documentation that explains checking value for NULL.

I have looked at this Article but that doesn't have information I need.

enter image description here

2
  • Do you want to render text area based on some user input>
    – Samir
    Feb 5, 2018 at 17:09
  • @Samir Yes, That is correct.
    – Ricky
    Feb 5, 2018 at 17:11

2 Answers 2

8

Use the empty string value '':

enter image description here

2
  • Just wondering as the answer of @Samir (the one below) can do the trick too, what will be best practice in general, using this filter or using the code <aura:if ...
    – manza
    Jun 14, 2018 at 23:39
  • 1
    @manza Coding this in to the component means you have to deploy code each time you make a change. If all you want are filters, you probably want to do it this way.
    – sfdcfox
    Jun 14, 2018 at 23:51
12

use <aura:if> to render the component based on the input of the text area. Pseudo code.

<aura:component>
  <aura:attribute name="strTest" type="String"/>

  <aura:if isTrue="{!not(empty(v.strTest))}">
  //TRUE - show your component here
  <aura:set attribute="else">
   False
  </aura:set>
 </aura:if> 

</aura:component
2
  • Can someone please explain how to implement this solution? The UI shown in OP's question does not allow code editing.
    – Garywoo
    Jul 28, 2020 at 17:27
  • This code can not be used with what was shown in UI. To put a visibility using the UI, refer to sfdxfox's answer above
    – Samir
    Jul 28, 2020 at 17:39

You must log in to answer this question.

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