Chapter 3: LWC Tutorial – Directives

Chapter 3: LWC Tutorial – Directives

On October 27, 2022, Posted by , In LWC Tutorial, With Comments Off on Chapter 3: LWC Tutorial – Directives
  1. If:true={property}  -> This directive simply adds or removes content from DOM depending on if property evaluates to true or false ie it displays content conditionally. Similarly, we have another directive if:false={property}
  1. For:each or Iterator ->  These are special directives that are used when we want to show a list of items. 

Iterator directive provides us with two special properties “first” and “last” which allow us to apply any special behavior to the first and the last item of the array.

While using these directives we have to also “key” attributes with each item. 

Key is used by the framework to re-render only those items in the list which are changed rather than going through the whole list.

Note: Key can only be String or number and is not reflected on DOM.

Comments are closed.