What you will learn
Synchronize form controls and component values with clear ownership.
- Two-way binding combines an input binding and an output listener. [(ngModel)] is useful for simple template-driven controls after importing FormsModule.
- For component communication, model() creates a model input with the corresponding change output. A parent can bind to it with the banana-in-a-box syntax.
- Use one source of truth. Do not bind the same control to ngModel and a reactive FormControl.
- For complex validation and dynamic form structures, prefer Signal Forms or Reactive Forms rather than a large template-driven form.
How it works
1Control emits change
2Model updates
3computed recalculates
4Template displays result
Expected result
Changing either number or operation updates the result immediately.
Common mistakes
Do not forget FormsModule in a standalone component. Number inputs may still require explicit Number conversion in calculations. Avoid two competing sources of truth.
