Getting error on when addAdd() call from html template.
this.personalForm = this.fb.group({
user: this.fb.group({
address: this.fb.array([this.addRows()])
}),
addRows() {
return this.fb.group({
country: ['']});
addAdd() {
const control:FormArray = this.personalForm.get[`address`] as FormArray;
control.push(this.addRows());
}
Where i am doing wrong
ERROR TypeError: Cannot read property 'push' of undefined
html code
<button (click)="addAdd()">Add Address</button>
<div formArrayName="address">
<div *ngFor="let add of personalForm.controls?.address?.controls; let i=index" [formGroupName]="i">
<label>Country</label>
<input type="text" class="form-control" formControlName="country"
placeholder="Country" />
</div>
</div>