Reactive forms provide explicit and fine-grained control over form state and validation in TypeScript, making them ideal for complex forms. Template-driven forms are simpler and rely more on HTML and directives.
Reactive forms use observables and update the form model immediately as the user types. Template-driven forms update the model on blur or on form submission.
import { FormGroup, FormControl, Validators } from '@angular/forms'; // Choose the correct initialization
Validators.required is passed as a function reference inside an array to the FormControl constructor. Option D correctly uses [Validators.required]. Option D misses the array, which is allowed but less flexible. Option D calls Validators.required as a function which is incorrect. Option D uses wrong syntax with curly braces.
Angular shows validation errors only after the control is touched or dirty. Without calling markAsTouched() or user interaction, errors won't display. Passing Validators.required directly is valid. Initial value can be empty string. updateOn is optional.
Angular does not automatically unsubscribe from observables like valueChanges. If you don't unsubscribe manually, the subscription stays active, causing memory leaks. It does not throw errors or complete automatically.