Skip to content

Commit

Permalink
controlvalueaccessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 22, 2021
1 parent d40802e commit 97a6f0a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/app/address-form/address-form.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<fieldset [formGroup]="form">

<legend>{{legend}}</legend>

<mat-form-field>

<input matInput
placeholder="Address Line 1"
formControlName="addressLine1">

</mat-form-field>

<mat-form-field>

<input matInput
placeholder="Address Line 2"
formControlName="addressLine2">

</mat-form-field>

<mat-form-field>

<input matInput
placeholder="Zip Code"
formControlName="zipCode">

</mat-form-field>

<mat-form-field>

<input matInput
placeholder="City"
formControlName="city">

</mat-form-field>

<div class="form-val">

{{form.value | json}}

</div>

<div class="form-val">

{{form.valid | json}}

</div>

</fieldset>
13 changes: 13 additions & 0 deletions src/app/address-form/address-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ import {noop, Subscription} from 'rxjs';
})
export class AddressFormComponent {

@Input()
legend:string;

form: FormGroup = this.fb.group({
addressLine1: [null, [Validators.required]],
addressLine2: [null, [Validators.required]],
zipCode: [null, [Validators.required]],
city: [null, [Validators.required]]
});

constructor(private fb: FormBuilder) {
}

}


Expand Down

0 comments on commit 97a6f0a

Please sign in to comment.