Skip to main content

Model Attribute

The $model directive creates a two-way data binding between form inputs and state properties.

Usage

~index.html
<input $model="propertyName" />

How it Works

  • The framework sets up event listeners for input changes.
  • When the input value changes, it updates the bound property in the state.
  • When the state property changes programmatically, it updates the input value.
  • The framework automatically keeps the view and state in sync.

Error Handling

If the specified property doesn't exist in the state, it might be created automatically or an error might be logged to the console.

Note

$model simplifies form handling by automatically synchronizing input values with state properties, reducing the need for manual event handling.