# Reactive Forms Reactive forms provide a model-driven approach to handling form inputs. They are built around observable streams and provide synchronous access to the data model, making them more scalable and testable than template-driven forms. ## Core Classes Reactive forms are built using these fundamental classes from `@angular/forms`: - `FormControl`: Manages the value and validity of an individual input. - `FormGroup`: Manages a group of controls (an object-like structure). - `FormArray`: Manages a numerically indexed array of controls. - `FormBuilder`: A service that provides factory methods for creating control instances. ## Setup Import `ReactiveFormsModule` into your component. ```ts import {Component, inject} from '@angular/core'; import {ReactiveFormsModule, FormGroup, FormControl, Validators, FormBuilder} from '@angular/forms'; @Component({ selector: 'app-profile-editor', imports: [ReactiveFormsModule], templateUrl: './profile-editor.component.html', }) export class ProfileEditor { private fb = inject(FormBuilder); // Using FormBuilder for concise definition profileForm = this.fb.group({ firstName: ['', Validators.required], lastName: [''], address: this.fb.group({ street: [''], city: [''], }), aliases: this.fb.array([this.fb.control('')]), }); onSubmit() { console.warn(this.profileForm.value); } } ``` ## Template Binding Use directives to bind the model to the view: - `[formGroup]`: Binds a `FormGroup` to a `