@title
Reactive Forms
@intro
Create a reactive form using FormBuilder, groups, and arrays.
@description
_Reactive forms_ is an Angular technique for creating forms in a _reactive_ style.
This guide explains reactive forms as you follow the steps to build a "Hero Detail Editor" form.
{@a toc}
## Contents
- [Introduction to reactive forms](guide/reactive-forms#intro)
- [Setup](guide/reactive-forms#setup)
- [Create a data model](guide/reactive-forms#data-model)
- [Create a _reactive forms_ component](guide/reactive-forms#create-component)
- [Create its template file](guide/reactive-forms#create-template)
- [Import the _ReactiveFormsModule_](guide/reactive-forms#import)
- [Display the _HeroDetailComponent_](guide/reactive-forms#update)
- [Add a FormGroup](guide/reactive-forms#formgroup)
- [Taking a look at the form model](guide/reactive-forms#json)
- [Introduction to _FormBuilder_](guide/reactive-forms#formbuilder)
- [Validators.required](guide/reactive-forms#validators)
- [Nested FormGroups](guide/reactive-forms#grouping)
- [Inspect _FormControl_ properties](guide/reactive-forms#properties)
- [Set form model data using _setValue_ and _patchValue_](guide/reactive-forms#set-data)
- [Use _FormArray_ to present an array of _FormGroups_](guide/reactive-forms#form-array)
- [Observe control changes](guide/reactive-forms#observe-control)
- [Save form data](guide/reactive-forms#save)
Try the Reactive Forms live-example.
You can also run the Reactive Forms Demo version
and choose one of the intermediate steps from the "demo picker" at the top.
{@a intro}
## Introduction to Reactive Forms
Angular offers two form-building technologies: _reactive_ forms and _template-driven_ forms.
The two technologies belong to the `@angular/forms` library
and share a common set of form control classes.
But they diverge markedly in philosophy, programming style, and technique.
They even have their own modules: the `ReactiveFormsModule` and the `FormsModule`.
### _Reactive_ forms
Angular _reactive_ forms facilitate a _reactive style_ of programming
that favors explicit management of the data flowing between
a non-UI _data model_ (typically retrieved from a server) and a
UI-oriented _form model_ that retains the states
and values of the HTML controls on screen. Reactive forms offer the ease
of using reactive patterns, testing, and validation.
With _reactive_ forms, you create a tree of Angular form control objects
in the component class and bind them to native form control elements in the
component template, using techniques described in this guide.
You create and manipulate form control objects directly in the
component class. As the component class has immediate access to both the data
model and the form control structure, you can push data model values into
the form controls and pull user-changed values back out. The component can
observe changes in form control state and react to those changes.
One advantage of working with form control objects directly is that value and validity updates
are [always synchronous and under your control](guide/reactive-forms#async-vs-sync "Async vs sync").
You won't encounter the timing issues that sometimes plague a template-driven form
and reactive forms can be easier to unit test.
In keeping with the reactive paradigm, the component
preserves the immutability of the _data model_,
treating it as a pure source of original values.
Rather than update the data model directly,
the component extracts user changes and forwards them to an external component or service,
which does something with them (such as saving them)
and returns a new _data model_ to the component that reflects the updated model state.
Using reactive form directives does not require you to follow all reactive priniciples,
but it does facilitate the reactive programming approach should you choose to use it.
### _Template-driven_ forms
_Template-driven_ forms, introduced in the [Template guide](guide/forms), take a completely different approach.
You place HTML form controls (such as `` and `