29 lines
798 B
TypeScript
29 lines
798 B
TypeScript
import { Component, OnInit, Input } from '@angular/core';
|
|
import { FormGroup, FormControl } from '@angular/forms';
|
|
import { Address } from '@nested-forms/contact';
|
|
|
|
@Component({
|
|
selector: 'nested-forms-address',
|
|
templateUrl: './address.component.html',
|
|
styleUrls: ['./address.component.css']
|
|
})
|
|
export class AddressComponent implements OnInit {
|
|
@Input() addressGroup: FormGroup;
|
|
|
|
static buildForm(addr: Address): FormGroup {
|
|
return new FormGroup({
|
|
line1: new FormControl(addr ? addr.line1 : ''),
|
|
line2: new FormControl(addr ? addr.line2 : ''),
|
|
city: new FormControl(addr ? addr.city : ''),
|
|
state: new FormControl(addr ? addr.state : ''),
|
|
postalCode: new FormControl(addr ? addr.postalCode : ''),
|
|
});
|
|
}
|
|
|
|
constructor() { }
|
|
|
|
ngOnInit() {
|
|
}
|
|
|
|
}
|