import { ChangeDetectionStrategy, Component, Input, OnInit, } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { Address } from '@nested-forms/contact'; @Component({ selector: 'nested-forms-address', templateUrl: './address.component.html', styleUrls: ['./address.component.css'], changeDetection: ChangeDetectionStrategy.OnPush, }) 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() {} }