K
K
kserg9032020-03-12 09:54:11
Angular
kserg903, 2020-03-12 09:54:11

How to fill a form consisting of formArray?

There is a form which consists of formArray. I am unable to populate it with values. Please tell me how to do it. Here is my attempt:

const f = this.form.get('loadingPlaces') as FormArray;
f.push({
fio: data.fio,
phoneNumber: data.phoneNumber,
});


Here is the structure of the form:
5e69dc8b1616f872270681.png

Here is the error message:
ERROR TypeError: ctrl.updateValueAndValidity is not a function

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
babtsoualiaksandr, 2020-03-12
@babtsoualiaksandr

public form = new FormArray([]);
public fio = new FormControl(data.fio);
public phoneNumber = new FormControl(data.phoneNumber);
ngOnInit() {
this.form.push(this.fio);
this.form.push(this.phoneNumber);
}
https://netbasal.com/angular-reactive-forms-the-ul...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question