Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 5d84faf

Browse files
Part way through Deborah's comments
1 parent 2640bc4 commit 5d84faf

File tree

8 files changed

+41
-38
lines changed

8 files changed

+41
-38
lines changed

public/docs/_examples/reactive-forms/ts/app/hero-signup-2.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- #docregion basic-form-->
2-
<form novalidate [formGroup]="form">
2+
<form novalidate [formGroup]="heroForm">
33
<div class="form-group">
44
<label>Name:</label>
55
<input class="form-control" formControlName="name">

public/docs/_examples/reactive-forms/ts/app/hero-signup-3.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- #docregion -->
2-
<form novalidate [formGroup]="form">
2+
<form novalidate [formGroup]="heroForm">
33
<div class="form-group">
44
<label>Name:</label>
55
<input class="form-control" formControlName="name">
@@ -35,4 +35,4 @@
3535
<label>Zip Code:</label>
3636
<input class="form-control" formControlName="zip">
3737
</div>
38-
</form>
38+
</form>

public/docs/_examples/reactive-forms/ts/app/hero-signup-4.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>Hero Sign Up</h2>
2-
<form novalidate [formGroup]="form">
2+
<form novalidate [formGroup]="heroForm">
33
<div class="form-group">
44
<label>Name:</label>
55
<input class="form-control" formControlName="name">

public/docs/_examples/reactive-forms/ts/app/hero-signup-5.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>Hero Sign Up</h2>
2-
<form novalidate [formGroup]="form">
2+
<form novalidate [formGroup]="heroForm">
33
<div class="form-group">
44
<label>Name:</label>
55
<input class="form-control" formControlName="name">

public/docs/_examples/reactive-forms/ts/app/hero-signup-versions.component.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
1313

1414
// #docregion v1
1515
export class HeroSignUpComponent1 {
16-
form = new FormGroup ({
16+
heroForm = new FormGroup ({
1717
name: new FormControl(),
1818
username: new FormControl(),
1919
password: new FormControl(),
@@ -29,9 +29,9 @@ export class HeroSignUpComponent1 {
2929
})
3030
// #docregion v2
3131
export class HeroSignUpComponent2 {
32-
form: FormGroup; // <--- form is of type FormGroup
32+
heroForm: FormGroup; // <--- heroForm is of type FormGroup
3333
constructor(private _fb: FormBuilder) { // <--- inject FormBuilder
34-
this.form = this._fb.group({ // <--- make this.form a FormBuilder group
34+
this.heroForm = this._fb.group({ // <--- make this.form a FormBuilder group
3535
name: '',
3636
username: '',
3737
password: '',
@@ -48,9 +48,9 @@ export class HeroSignUpComponent2 {
4848
})
4949
// #docregion v3
5050
export class HeroSignUpComponent3 {
51-
form: FormGroup;
51+
heroForm: FormGroup;
5252
constructor(private _fb: FormBuilder) {
53-
this.form = this._fb.group({
53+
this.heroForm = this._fb.group({
5454
name: '',
5555
username: '',
5656
password: '',
@@ -71,9 +71,9 @@ export class HeroSignUpComponent3 {
7171
})
7272
// #docregion v4
7373
export class HeroSignUpComponent4 {
74-
form: FormGroup;
74+
heroForm: FormGroup;
7575
constructor(private _fb: FormBuilder) {
76-
this.form = this._fb.group({
76+
this.heroForm = this._fb.group({
7777
name: '',
7878
username: '',
7979
password: '',
@@ -96,9 +96,9 @@ export class HeroSignUpComponent4 {
9696
})
9797
// #docregion v5
9898
export class HeroSignUpComponent5 {
99-
form: FormGroup;
99+
heroForm: FormGroup;
100100
constructor(private _fb: FormBuilder) {
101-
this.form = this._fb.group({
101+
this.heroForm = this._fb.group({
102102
name: '',
103103
username: '',
104104
password: '',
@@ -110,7 +110,7 @@ export class HeroSignUpComponent5 {
110110
zip: ''
111111
})
112112
});
113-
this.form.patchValue({
113+
this.heroForm.patchValue({
114114
name: 'Nancy'
115115
});
116116
}
@@ -124,9 +124,9 @@ export class HeroSignUpComponent5 {
124124
})
125125
// #docregion v6
126126
export class HeroSignUpComponent6 {
127-
form: FormGroup;
127+
heroForm: FormGroup;
128128
constructor(private _fb: FormBuilder) {
129-
this.form = this._fb.group({
129+
this.heroForm = this._fb.group({
130130
name: '',
131131
username: '',
132132
password: '',
@@ -139,7 +139,7 @@ export class HeroSignUpComponent6 {
139139
})
140140
});
141141
// #docregion set-value
142-
this.form.setValue({
142+
this.heroForm.setValue({
143143
name: 'Nancy',
144144
username: 'NancyD',
145145
password: '',
@@ -164,12 +164,12 @@ export class HeroSignUpComponent6 {
164164
// #docregion v7
165165
export class HeroSignUpComponent7 {
166166
// #docregion addresses
167-
form: FormGroup;
167+
heroForm: FormGroup;
168168
addresses: FormArray; // <--add this under form
169169
// #enddocregion addresses
170170

171171
constructor(private _fb: FormBuilder) {
172-
this.form = this._fb.group({
172+
this.heroForm = this._fb.group({
173173
name: '',
174174
username: '',
175175
password: '',

public/docs/_examples/reactive-forms/ts/app/hero-signup.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>Hero Sign Up</h2>
2-
<form novalidate [formGroup]="form">
2+
<form novalidate [formGroup]="heroForm">
33
<div class="form-group">
44
<label>Name:</label>
55
<input class="form-control" formControlName="name">

public/docs/_examples/reactive-forms/ts/app/hero-signup.component.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
1010
templateUrl: './hero-signup.component.html'
1111
})
1212
// #enddocregion reactive-comp-metadata
13-
@Component({
14-
moduleId: module.id,
15-
selector: 'hero-signup-7',
16-
templateUrl: './hero-signup-5.component.html'
17-
})
1813

1914
export class HeroSignUpComponent {
2015
form: FormGroup;

public/docs/ts/latest/guide/reactive-forms.jade

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ a#create-comp
5959
- `FormGroup`: Allows you to group **FormControls**,
6060
**FormArrays**, and other **FormGroups**.
6161

62-
Below the import statements, use the `@Component` decorator
62+
Above the class, use the `@Component` decorator
6363
to provide metadata to Angular:
6464

6565
+makeExample('reactive-forms/ts/app/hero-signup.component.ts', 'reactive-comp-metadata','app/hero-signup.component.ts (excerpt)')(format=".")
@@ -103,8 +103,8 @@ a#create-template
103103
:marked
104104
On the `<form>` tag, `novalidate` prevents the browser
105105
from attempting any native validations
106-
and `[formGroup]="form"` lets Angular know that this is the
107-
form you’re referring to in the component class.
106+
and `[formGroup]="heroForm"` lets Angular know that this is the
107+
form property you’re referring to in the component class.
108108

109109
.l-sub-section
110110
:marked
@@ -172,17 +172,23 @@ a#formbuilder
172172

173173
Then use the constructor method and inject `FormBuilder` with
174174
`constructor(public fb: FormBuilder)`. Inside the constructor,
175-
you can use `FormBuilder` to set the `form` as a group, which
175+
you can use `FormBuilder` to set the `heroForm` as a group, which
176176
lets you instantiate the **FormControls** by simply using the
177-
`formControlName` and in this case, an empty value. In this
177+
`formControlName` and in this case, an empty value. In this
178178
way, `FormBuilder` instantiates each `FormControl` for you,
179179
reducing repetitive code. Now, you don't have to use `new`
180180
over and over.
181181

182182
+makeExample('reactive-forms/ts/app/hero-signup-versions.component.ts', 'v2','app/hero-signup.component.ts (excerpt)')(format=".")
183183

184+
.alert.is-important
185+
:marked
186+
You could provide a value for any of the **FormControls**, for
187+
example `name: 'Nancy'` populates the input with "Nancy".
188+
184189
:marked
185-
This form looks great, but are the model and template talking?
190+
This form looks great, but are the user's entries in the
191+
view reflected in the form model?
186192
To inspect what’s going on, add this after the
187193
closing `form` tag in `app.component.html`:
188194

@@ -203,7 +209,6 @@ figure.image-display
203209
suddenly managing lots of individual
204210
**FormControls**, you need a way to organize them.
205211

206-
207212
.l-main-section
208213
a#grouping
209214
:marked
@@ -306,21 +311,24 @@ table(width="100%")
306311
td
307312
:marked
308313
Returns the status of a `FormControl` as valid,
309-
invalid - **KARA, CAN YOU HELP ME HERE?**.
314+
invalid, pending, or disabled.
310315
tr
311316
td <code>myControl.pristine</code>
312317
td
313318
:marked
314-
**KARA, CAN YOU HELP ME HERE, TOO?**.
319+
Returns a boolean dependant on whether or
320+
not the user has changed the value in the UI.
315321
tr
316322
td <code>myControl.untouched</code>
317323
td
318324
:marked
319-
**KARA, CAN YOU HELP ME HERE, TOO?**.
325+
Returns a boolean. A control is untouched if
326+
the user has not yet triggered a blur event on it.
327+
320328
:marked
321329
These are just a few examples to give you an idea of what's
322-
available. To read more about
323-
**WHERE SHOULD I LINK TO? THE API REF DOESN'T GO INTO THESE METHODS**
330+
available. To read more about these and other properties,
331+
see [AbstractControl](../api/forms/index/AbstractControl-class.html).
324332

325333
You can inspect an individual `FormControl` in the demo, such
326334
as the one for Name, by using the `.get()` method.

0 commit comments

Comments
 (0)