Пожалуйста, помогите, я пытаюсь просмотреть данные из компонента в представление, используя массив угловых форм.следующее решение: Angular 5 FormArray получить данные из базы данных и показать строки .помогло мне, но теперь я испытываю проблему, когда первый индекс массива формы всегда равен нулю, и я получаю следующие ошибки:
ERROR Error: Cannot find control with path: '[object Object] -> 0'
at _throwError (forms.js:2432)
at setUpFormContainer (forms.js:2405)
at FormGroupDirective.addFormGroup (forms.js:6691)
at FormGroupName.AbstractFormGroupDirective.ngOnInit (forms.js:2568)
...
Cannot read property 'controls' of undefined
at Object.eval [as updateDirectives]
...
в моем ngOnInit у меня есть только следующее:
this.SectionForm= this.formBuilder.group({
sectionData: this.formBuilder.array([this.buildDevelopmentSector()])
});
this.activatedRoute.params.subscribe(res =>
// get data and push the data to a formArray called sectionDataArray
this.GetDataFromApi(res.requestId)
);
представление имеет следующую часть:
<div [formGroup] ="SectionForm">
<div [formArrayName]="sectionDataArray">
<div *ngFor="let section of sectionDataArray.controls ; let i = index" [formGroupName]="i">
...
...
...
</div>
Глядя на журналы, я вижу следующее:
0:
amount:""
percentage:""
name:""
quantity:""
__proto__:Object
1:
amount:1200000
percentage:23
name: "Repo"
quantity:20000
__proto__:Object
length:2
__proto__:Array(0)