|
| 1 | +/* tslint:disable:component-class-suffix */ |
| 2 | +// #docplaster |
| 3 | +// #docregion |
| 4 | +import { Component } from '@angular/core'; |
| 5 | +import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; |
| 6 | + |
| 7 | +@Component({ |
| 8 | + moduleId: module.id, |
| 9 | + selector: 'hero-signup-1', |
| 10 | + templateUrl: './hero-signup-1.component.html' |
| 11 | +}) |
| 12 | +// #docregion v1 |
| 13 | +export class HeroSignUpComponent1 { |
| 14 | + form = new FormGroup ({ |
| 15 | + name: new FormControl(), |
| 16 | + username: new FormControl(), |
| 17 | + password: new FormControl(), |
| 18 | + confirm: new FormControl() |
| 19 | + }); |
| 20 | +} |
| 21 | +// #enddocregion v1 |
| 22 | + |
| 23 | +@Component({ |
| 24 | + moduleId: module.id, |
| 25 | + selector: 'hero-signup-2', |
| 26 | + templateUrl: './hero-signup-2.component.html' |
| 27 | +}) |
| 28 | +// #docregion v2 |
| 29 | +export class HeroSignUpComponent2 { |
| 30 | + form: FormGroup; |
| 31 | + constructor(private _fb: FormBuilder) { |
| 32 | + this.form = this._fb.group({ |
| 33 | + name: '', |
| 34 | + username: '', |
| 35 | + password: '', |
| 36 | + confirm: '' |
| 37 | + }); |
| 38 | + } |
| 39 | +} |
| 40 | +// #enddocregion v2 |
| 41 | + |
| 42 | +@Component({ |
| 43 | + moduleId: module.id, |
| 44 | + selector: 'hero-signup-3', |
| 45 | + templateUrl: './hero-signup-3.component.html' |
| 46 | +}) |
| 47 | +// #enddocregion v3 |
| 48 | +export class HeroSignUpComponent3 { |
| 49 | + form: FormGroup; |
| 50 | + constructor(private _fb: FormBuilder) { |
| 51 | + this.form = this._fb.group({ |
| 52 | + name: '', |
| 53 | + username: '', |
| 54 | + password: '', |
| 55 | + confirm: '', |
| 56 | + street: '', |
| 57 | + city: '', |
| 58 | + state: '', |
| 59 | + zip: '' |
| 60 | + }); |
| 61 | + } |
| 62 | +} |
| 63 | +// #enddocregion v3 |
| 64 | + |
| 65 | +@Component({ |
| 66 | + moduleId: module.id, |
| 67 | + selector: 'hero-signup-4', |
| 68 | + templateUrl: './hero-signup-4.component.html' |
| 69 | +}) |
| 70 | +// #enddocregion v4 |
| 71 | +export class HeroSignUpComponent4 { |
| 72 | + form: FormGroup; |
| 73 | + constructor(private _fb: FormBuilder) { |
| 74 | + this.form = this._fb.group({ |
| 75 | + name: '', |
| 76 | + username: '', |
| 77 | + password: '', |
| 78 | + confirm: '', |
| 79 | + address: this._fb.group({ |
| 80 | + street: '', |
| 81 | + city: '', |
| 82 | + state: '', |
| 83 | + zip: '' |
| 84 | + }) |
| 85 | + }); |
| 86 | + } |
| 87 | +} |
| 88 | +// #enddocregion v4 |
| 89 | + |
| 90 | +@Component({ |
| 91 | + moduleId: module.id, |
| 92 | + selector: 'hero-signup-5', |
| 93 | + templateUrl: './hero-signup-5.component.html' |
| 94 | +}) |
| 95 | +// #docregion v5 |
| 96 | +export class HeroSignUpComponent5 { |
| 97 | + form: FormGroup; |
| 98 | + constructor(private _fb: FormBuilder) { |
| 99 | + this.form = this._fb.group({ |
| 100 | + name: '', |
| 101 | + username: '', |
| 102 | + password: '', |
| 103 | + confirm: '', |
| 104 | + address: this._fb.group({ |
| 105 | + street: '', |
| 106 | + city: '', |
| 107 | + state: '', |
| 108 | + zip: '' |
| 109 | + }) |
| 110 | + }); |
| 111 | + |
| 112 | + this.form.patchValue({ |
| 113 | + name: 'Nancy' |
| 114 | + }); |
| 115 | + } |
| 116 | +} |
| 117 | +// #enddocregion v5 |
| 118 | + |
| 119 | +@Component({ |
| 120 | + moduleId: module.id, |
| 121 | + selector: 'hero-signup-6', |
| 122 | + templateUrl: './hero-signup-6.component.html' |
| 123 | +}) |
| 124 | +// #docregion v6 |
| 125 | +export class HeroSignUpComponent6 { |
| 126 | + form: FormGroup; |
| 127 | + constructor(private _fb: FormBuilder) { |
| 128 | + this.form = this._fb.group({ |
| 129 | + name: '', |
| 130 | + username: '', |
| 131 | + password: '', |
| 132 | + confirm: '', |
| 133 | + address: this._fb.group({ |
| 134 | + street: '', |
| 135 | + city: '', |
| 136 | + state: '', |
| 137 | + zip: '' |
| 138 | + }) |
| 139 | + }); |
| 140 | + |
| 141 | + this.form.setValue({ |
| 142 | + name: 'Nancy', |
| 143 | + username: 'NancyD', |
| 144 | + password: '', |
| 145 | + confirm: '', |
| 146 | + address: { |
| 147 | + street: '123 Fake Street', |
| 148 | + city: 'San Francisco', |
| 149 | + state: 'CA', |
| 150 | + zip: '12345' |
| 151 | + } |
| 152 | + }); |
| 153 | + } |
| 154 | +} |
| 155 | +// #enddocregion v6 |
| 156 | + |
| 157 | +export const components = [ |
| 158 | + HeroSignUpComponent1, |
| 159 | + HeroSignUpComponent2, |
| 160 | + HeroSignUpComponent3, |
| 161 | + HeroSignUpComponent4, |
| 162 | + HeroSignUpComponent5, |
| 163 | + HeroSignUpComponent6, |
| 164 | +]; |
0 commit comments