@@ -55,7 +55,7 @@ a#intro
5555 in the component class and bind them to native form control elements in the
5656 component template, using techniques described in this guide.
5757
58- With reactive forms, you create and manipulate form control objects directly in the
58+ You create and manipulate form control objects directly in the
5959 component class. As the component class has immediate access to both the data
6060 model and the form control structure, you can push data model values into
6161 the form controls and pull user-changed values back out. The component can
@@ -90,7 +90,6 @@ a#intro
9090 Angular updates the mutable _data model_ with user changes as they happen.
9191
9292 When writing in a reactive style, you rarely, if ever, use two-way data binding.
93- For this reason, the `ngModel` directive is not part of the ReactiveFormsModule.
9493
9594 These differences reflect two architectural paradigms,
9695 with their own strengths and weaknesses,
@@ -173,11 +172,16 @@ a#create-template
173172:marked
174173 ## Create the template
175174
176-
177175 Now create the component's template, `app/hero-detail.component.html`, with the following markup.
178176
179177+ makeExample('reactive-forms/ts/app/hero-detail-1.component.html' , 'simple-control' ,'app/hero-detail.component.html' )( format ="." )
180178
179+ :marked
180+ To let Angular know that this is the input that you want to
181+ associate to the `name` `FormControl` in the class,
182+ you need `[formControl]="name"` in the template on the `<input>`.
183+
184+
181185.l-sub-section
182186 :marked
183187 Disregard the `form-control` _CSS_ class. It belongs to the
@@ -189,8 +193,8 @@ a#import
189193:marked
190194 ## Import the _ReactiveFormsModule_
191195
192- The HeroDetailComponent template uses `formGroup` and ` formControlName`
193- directives from the `ReactiveFormsModule`.
196+ The HeroDetailComponent template uses `formControlName`
197+ directive from the `ReactiveFormsModule`.
194198
195199 In this sample, you declare the `HeroDetailComponent` in the `AppModule`.
196200 Therefore, do the following three things in `app.module.ts`:
@@ -249,7 +253,8 @@ figure.image-display
249253a#formgroup
250254:marked
251255 ## Add a FormGroup
252- Usually, *FormControls* reside within a `FormGroup`.
256+ Usually, if you have multiple *FormControls*, you'll want to register
257+ them within a parent `FormGroup`.
253258 This is simple to do. To add a `FormGroup`, add it to the imports section
254259 of `hero-detail.component.ts`:
255260
@@ -362,7 +367,9 @@ a#validators
362367:marked
363368 Then, you can easily make the `name` `FormControl` required by supplying the `name`
364369 property in the class with an array that holds two arguments,
365- the initial value for `name` and `Validators.required`.
370+ the initial value for `name` and `Validators.required`. By contrast,
371+ in template driven forms, you must wrap validators in a directive.
372+ Reactive validators are simple, composable functions.
366373
367374+ makeExample('reactive-forms/ts/app/hero-detail-3.component.ts' , 'required' ,'app/hero-detail.component.ts (excerpt)' )( format ="." )
368375
@@ -597,8 +604,8 @@ a#set-data
597604 error messages if you have a typo or if you've nested controls incorrectly.
598605 `patchValue` will fail silently.
599606
600- If you have a typo or nested controls incorrectly, `setValue` will catch
601- the error and report it clearly. `patchValue` will fail silently.
607+ On the other hand, `setValue` will catch
608+ the error and report it clearly.
602609
603610 Notice that you can _almost_ use the entire `hero` as the argument to `setValue`
604611 because its shape is similar to the component's `FormGroup` structure.
@@ -964,7 +971,7 @@ a#appendix
964971 This also affects testing of template-driven forms. You always
965972 have to wrap your test block in `async()` or `fakeAsync()` to
966973 avoid looking for values in the form that aren't available yet.
967- With reactive forms, you don't everything is available
974+ With reactive forms, everything is available
968975 when you expect it to be.
969976
970977
0 commit comments