Performance: Why reactive forms are preferred
MEDIUM IMPACT
Reactive forms improve user input responsiveness and reduce unnecessary DOM updates during form interactions.
Reactive form using FormGroup and FormControl with explicit valueChanges subscriptions and validation logic in componentTemplate-driven form with two-way binding [(ngModel)] on many inputs and validations in template| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Template-driven forms with [(ngModel)] | High number of DOM updates per input | Multiple reflows per keystroke | High paint cost due to frequent updates | [X] Bad |
| Reactive forms with FormGroup/FormControl | Minimal DOM updates, controlled by code | Single reflow per input change | Lower paint cost with targeted updates | [OK] Good |