Skip to main content

Posts

Showing posts with the label if:true

Conditional Rendering in LWC?

 There are 2 special directive which is being used for conditional rendering of DOM element.   1.  if:true    2. if:false  <template if:true={expression}>     Render when expression is true  </template>     <template if:false={expression}>     Render when expression is false  </template> Notes -  1. Expression can be JavaScript property 2. Can be property of an object defined in JavaScript. example {employee.name} 3. Ternary operator can not be used inside expression. 4. Array also can not be used in the expression. 5. To use computed value use getters.  Here is component code which have if-true if-false also computed expression in if-directive. < template >     < lightning-card title = "Conditional Rendering" >         < div class = "slds-m-around_medium" >             < lightning-button   ...