Skip to main content

What does the formGroup directive do?

formGroup is a directive that binds an HTML form or container to a FormGroup object in reactive forms.

It:

  • combines several FormControl instances into one logical group;
  • lets Angular track the state and validation of the whole form at once;
  • makes it possible to pass the whole form into the component (form.value, form.valid, and so on).

Example:

typescript
form = new FormGroup({ name: new FormControl(''), email: new FormControl('') });
html
<form [formGroup]="form" (ngSubmit)="onSubmit()"> <input formControlName="name"> <input formControlName="email"> </form>

The formGroup directive connects the template and the form model, so Angular can manage their synchronization and state.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.