Skip to content

Commit 97a6f0a

Browse files
author
Your Name
committed
controlvalueaccessor
1 parent d40802e commit 97a6f0a

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<fieldset [formGroup]="form">
2+
3+
<legend>{{legend}}</legend>
4+
5+
<mat-form-field>
6+
7+
<input matInput
8+
placeholder="Address Line 1"
9+
formControlName="addressLine1">
10+
11+
</mat-form-field>
12+
13+
<mat-form-field>
14+
15+
<input matInput
16+
placeholder="Address Line 2"
17+
formControlName="addressLine2">
18+
19+
</mat-form-field>
20+
21+
<mat-form-field>
22+
23+
<input matInput
24+
placeholder="Zip Code"
25+
formControlName="zipCode">
26+
27+
</mat-form-field>
28+
29+
<mat-form-field>
30+
31+
<input matInput
32+
placeholder="City"
33+
formControlName="city">
34+
35+
</mat-form-field>
36+
37+
<div class="form-val">
38+
39+
{{form.value | json}}
40+
41+
</div>
42+
43+
<div class="form-val">
44+
45+
{{form.valid | json}}
46+
47+
</div>
48+
49+
</fieldset>

src/app/address-form/address-form.component.ts

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ import {noop, Subscription} from 'rxjs';
1717
})
1818
export class AddressFormComponent {
1919

20+
@Input()
21+
legend:string;
22+
23+
form: FormGroup = this.fb.group({
24+
addressLine1: [null, [Validators.required]],
25+
addressLine2: [null, [Validators.required]],
26+
zipCode: [null, [Validators.required]],
27+
city: [null, [Validators.required]]
28+
});
29+
30+
constructor(private fb: FormBuilder) {
31+
}
32+
2033
}
2134

2235

0 commit comments

Comments
 (0)