2019-08-28 04:17:08 +00:00
|
|
|
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
2019-09-05 01:36:09 +00:00
|
|
|
import { Address } from '@nested-forms/contact';
|
2019-08-28 04:17:08 +00:00
|
|
|
import { Component, OnInit, Input } from '@angular/core';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'nested-forms-address-list',
|
|
|
|
templateUrl: './address-list.component.html',
|
|
|
|
styleUrls: ['./address-list.component.css']
|
|
|
|
})
|
|
|
|
export class AddressListComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input() addresses: Address[];
|
|
|
|
@Input() parent: FormGroup;
|
|
|
|
|
|
|
|
arrayGroup: FormArray;
|
|
|
|
|
|
|
|
constructor(private fb: FormBuilder) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.arrayGroup = this.fb.array([]);
|
|
|
|
if (this.parent) {
|
|
|
|
this.parent.addControl('addresses', this.arrayGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|