Overview
ThehelloBinding component demonstrates two-way data binding in Lightning Web Components. It shows how to update a component property when a user interacts with an input field, creating a dynamic and interactive user experience.
What It Does
This component displays a greeting message that updates in real-time as the user types in an input field. When the user changes the input value, thehandleChange event handler updates the greeting property, which is reflected immediately in the displayed message.
Component Code
Key Concepts
- Event Handling: The
onchangeevent handler listens for changes to the input field - Reactive Properties: When
greetingis updated, the template automatically re-renders - Two-Way Binding: The input field’s value is bound to
greeting, and changes update the property - Event Object: The
event.target.valueprovides access to the current input value
How It Works
- The input field displays the current value of
greeting(initially “World”) - When the user types in the input field, the
onchangeevent fires - The
handleChangemethod updatesgreetingwith the new input value - The template reactively updates to show the new greeting message
