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

Commit 4b2259a

Browse files
committed
docs(reactive-forms): sample docregion cleaning
1 parent d48afe2 commit 4b2259a

11 files changed

+38
-62
lines changed

public/docs/_examples/reactive-forms/ts/app/demo.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* tslint:disable:member-ordering */
2-
// #docregion
32
import { Component } from '@angular/core';
43

54
import { Hero } from './data-model';

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
4-
52
// #docregion imports
6-
import { Component } from '@angular/core';
3+
import { Component } from '@angular/core';
74
import { FormControl, FormGroup } from '@angular/forms';
85
// #enddocregion
96

10-
//////// 1 ////////////////////////
11-
127
@Component({
138
moduleId: module.id,
149
selector: 'hero-detail-1',

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
42
// #docregion imports
5-
import { Component } from '@angular/core';
3+
import { Component } from '@angular/core';
64
import { FormBuilder, FormGroup } from '@angular/forms';
75
// #enddocregion imports
86

9-
//////// 2 ////////////////////////
10-
117
@Component({
128
moduleId: module.id,
139
selector: 'hero-detail-2',

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
4-
52
// #docregion imports
6-
import { Component } from '@angular/core';
3+
import { Component } from '@angular/core';
74
import { FormBuilder, FormGroup } from '@angular/forms';
5+
86
import { states } from './data-model';
97
// #enddocregion imports
108

11-
//////// 3 ////////////////////////
12-
139
@Component({
1410
moduleId: module.id,
1511
selector: 'hero-detail-3',

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
4-
5-
import { Component } from '@angular/core';
2+
import { Component } from '@angular/core';
63
import { FormBuilder, FormGroup } from '@angular/forms';
7-
import { states } from './data-model';
84

9-
10-
////////// 4 /////////////////////
5+
import { states } from './data-model';
116

127
@Component({
138
moduleId: module.id,

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
4-
// #docregion imports
2+
// #docregion import-input
53
import { Component, Input, OnChanges } from '@angular/core';
6-
import { FormBuilder, FormGroup } from '@angular/forms';
4+
// #enddocregion import-input
5+
import { FormBuilder, FormGroup } from '@angular/forms';
6+
7+
// #docregion import-hero
78
import { Hero, states } from './data-model';
8-
// #enddocregion imports
9+
// #enddocregion import-hero
910

1011
////////// 5 ////////////////////
1112

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
4-
2+
// #docregion imports
53
import { Component, Input, OnChanges } from '@angular/core';
6-
import { FormBuilder, FormGroup } from '@angular/forms';
7-
import { Address, Hero, states } from './data-model';
4+
import { FormBuilder, FormGroup } from '@angular/forms';
85

9-
10-
///////// 6 ////////////////////
6+
import { Address, Hero, states } from './data-model';
7+
// #enddocregion imports
118

129
@Component({
1310
moduleId: module.id,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
/* tslint:disable:component-class-suffix */
2-
// #docplaster
3-
// #docregion
42
// #docregion imports
5-
import { Component, Input, OnChanges } from '@angular/core';
3+
import { Component, Input, OnChanges } from '@angular/core';
64
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
5+
76
import { Address, Hero, states } from './data-model';
87
// #enddocregion imports
98

10-
////////// 7 ////////////////////
11-
129
@Component({
1310
moduleId: module.id,
1411
selector: 'hero-detail-7',
15-
templateUrl: './hero-detail-5.component.html'
12+
templateUrl: './hero-detail-7.component.html'
1613
})
1714
// #docregion v7
1815
export class HeroDetailComponent7 implements OnChanges {
@@ -21,9 +18,12 @@ export class HeroDetailComponent7 implements OnChanges {
2118
heroForm: FormGroup;
2219
states = states;
2320

21+
// #docregion ctor
2422
constructor(private fb: FormBuilder) {
2523
this.createForm();
24+
this.logNameChange();
2625
}
26+
// #enddocregion ctor
2727

2828
createForm() {
2929
// #docregion secretLairs-form-array
@@ -34,6 +34,8 @@ export class HeroDetailComponent7 implements OnChanges {
3434
// #enddocregion secretLairs-form-array
3535
}
3636

37+
logNameChange() {/* Coming soon */}
38+
3739
// #docregion onchanges
3840
ngOnChanges() {
3941
// #docregion reset-refactor
@@ -65,5 +67,3 @@ export class HeroDetailComponent7 implements OnChanges {
6567
}
6668
// #enddocregion add-lair
6769
}
68-
// #enddocregion v7
69-

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// tslint:disable:no-unused-variable
22
// #docplaster
33
// #docregion
4-
// #docregion reactive-comp-imports
4+
// #docregion imports
55
import { Component, EventEmitter, Input, Output, OnChanges } from '@angular/core';
66
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
77
import { Address, Hero, states } from './data-model';
8-
// #enddocregion reactive-comp-imports
8+
// #enddocregion imports
99

10-
// #docregion reactive-comp-metadata
10+
// #docregion metadata
1111
@Component({
1212
moduleId: module.id,
1313
selector: 'hero-detail',
1414
templateUrl: './hero-detail.component.html'
1515
})
16-
// #enddocregion reactive-comp-metadata
16+
// #enddocregion metadata
1717
export class HeroDetailComponent implements OnChanges {
1818
@Input() hero: Hero;
1919
// #docregion save-emitter

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ a#create-component
133133
:marked
134134
Now enter the `@Component` decorator that specifies the `HeroDetailComponent` metadata:
135135

136-
+makeExample('reactive-forms/ts/app/hero-detail.component.ts', 'reactive-comp-metadata','app/hero-detail.component.ts (excerpt)')(format=".")
136+
+makeExample('reactive-forms/ts/app/hero-detail.component.ts', 'metadata','app/hero-detail.component.ts (excerpt)')(format=".")
137137

138138
:marked
139139
The `moduleId: module.id` lets you use
@@ -450,7 +450,9 @@ a#data-model-form-model
450450
The `HeroDetailComponent` should display values of a hero,
451451
possibly a hero retrieved from a remote server.
452452

453-
The hero from the server is the **_data model_**.
453+
In this app, the `HeroDetailComponent` gets its hero from a parent `HeroListComponent`
454+
455+
The `hero` from the server is the **_data model_**.
454456
The `FormControl` structure is the **_form model_**.
455457

456458
The component must copy the hero values in the _data model_ into the _form model_.
@@ -490,13 +492,8 @@ a#data-model-form-model
490492
+makeExample('reactive-forms/ts/app/hero-detail-6.component.ts', 'address-form-group')(format=".")
491493

492494
:marked
493-
Also be sure to update the imports so that you can use the `Hero` object:
494-
+makeExample('reactive-forms/ts/app/hero-detail-5.component.ts', 'imports')(format=".")
495-
496-
:marked
497-
## Ward, `hero-detail-5.component.ts` is where `@Input() hero: Hero;`
498-
## shows up for the first time, but I don't understand it or know where
499-
## I should mention it. It seems like this is the general area, but we don't demonstrate it.
495+
Also be sure to update the import from `data-model` so you can reference the `Hero` class:
496+
+makeExample('reactive-forms/ts/app/hero-detail-5.component.ts', 'import-hero')(format=".")
500497

501498
.l-main-section
502499
a#set-data
@@ -726,11 +723,11 @@ a#form-array
726723
You'll re-use that index to compose a unique label for each address.
727724

728725
Here's the skeleton for the _secret lairs_ section of the HTML template:
729-
+makeExample('reactive-forms/ts/app/hero-detail-5.component.html', 'form-array-skeleton','app/hero-detail.component.html (*ngFor)')(format=".")
726+
+makeExample('reactive-forms/ts/app/hero-detail-7.component.html', 'form-array-skeleton','app/hero-detail.component.html (*ngFor)')(format=".")
730727

731728
:marked
732729
Here's the complete template for the _secret lairs_ section:
733-
+makeExample('reactive-forms/ts/app/hero-detail-5.component.html', 'form-array','app/hero-detail.component.html (excerpt)')
730+
+makeExample('reactive-forms/ts/app/hero-detail-7.component.html', 'form-array','app/hero-detail.component.html (excerpt)')
734731

735732
:marked
736733
### Add a new lair to the _FormArray_
@@ -741,7 +738,7 @@ a#form-array
741738
:marked
742739
Place a button on the form so the user can add a new _secret lair_ and wire it to the component's `addLair` method.
743740

744-
+makeExample('reactive-forms/ts/app/hero-detail-5.component.html', 'add-lair','app/hero-detail.component.html (addLair button)')(format=".")
741+
+makeExample('reactive-forms/ts/app/hero-detail-7.component.html', 'add-lair','app/hero-detail.component.html (addLair button)')(format=".")
745742

746743
.alert.is-important
747744
:marked
@@ -790,7 +787,7 @@ a#observe-control
790787

791788
:marked
792789
Call it in the constructor, after creating the form.
793-
+makeExample('reactive-forms/ts/app/hero-detail.component.ts', 'ctor')(format=".")
790+
+makeExample('reactive-forms/ts/app/hero-detail-7.component.ts', 'ctor')(format=".")
794791

795792
:marked
796793
The `logNameChange` method pushes name-change values into a `nameChangeLog` array.

0 commit comments

Comments
 (0)