Conditional Rendering in LWC
HTML:
I’m visible
You can’t see me!
You see me!
JS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import { LightningElement } from 'lwc'; export default class HelloConditionalRendering extends LightningElement { isVisible = false name handleClick(){ this.isVisible = true } changeHandler(event){ this.name = event.target.value } get helloMethod(){ return this.name === 'hello' } } |
Use Getters and Setters Template Looping in LWC