Reactive Forms
ReactiveFormsModule, FormControl, FormGroup, FormArray, FormBuilder, validators, custom validators, async validators, valueChanges
1What is a FormControl in Angular?
What is a FormControl in Angular?
Answer
FormControl is the fundamental class of Angular reactive forms that represents an individual form field. It encapsulates the field's value, validation state, and provides methods to handle user interactions. Each FormControl can have validators, react to changes via observables, and maintain states like touched, dirty, or pristine. It's the basic building block for constructing complex reactive forms with FormGroup or FormArray.
2Which Angular module must be imported to use reactive forms?
Which Angular module must be imported to use reactive forms?
Answer
ReactiveFormsModule is the Angular module that provides all the classes and directives needed to work with reactive forms. It must be imported in the application module or in a standalone component to access FormControl, FormGroup, FormBuilder and other APIs. Without this import, directives like formControlName or formGroup won't be recognized. FormsModule is a different module used for template-driven forms.
3What is a FormGroup in Angular?
What is a FormGroup in Angular?
Answer
FormGroup is a class that groups multiple FormControl or other FormGroup instances under named keys, allowing complex forms to be structured. It enables validating and managing the state of a set of fields as a single unit. For example, an address form can be a FormGroup containing street, city, and postal code fields. FormGroup automatically aggregates the values and validation states of all its child controls.
What is the purpose of FormBuilder in Angular?
How to create a FormControl with an initial value?
+23 interview questions
Other Angular interview topics
TypeScript Basics
TypeScript Advanced
Angular Fundamentals
Components & Lifecycle
Services & Dependency Injection
Angular Modules Organization
Angular CLI
Directives & Pipes
Routing & Navigation
Template-driven Forms
RxJS Fundamentals
RxJS Operators
HttpClient & API Calls
Basic State Management
Change Detection
Angular Signals
Standalone Components
Angular Unit Testing
End-to-End Testing
Build & Optimization
NgRx Fundamentals
NgRx Advanced
Angular Architecture
Performance Optimization
Security & Best Practices
Advanced RxJS Patterns
Angular Universal & SSR
Angular Micro-frontends
Master Angular for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free