组件代码为:
this.orderForm = this.formBuilder.group({
items: this.formBuilder.array([])
});
表格为:
<form [formGroup]="orderForm">
<div
class="form-group"
formArrayName="items"
*ngFor="let item of orderForm.get('items').controls; let i = index"
>
</div>
</form>
我收到错误消息:
类型“ AbstractControl”上不存在属性“控件”。
我该如何解决:
答案 0 :(得分:2)
尝试这样
get items() : FormArry {
return this.orderForm.get('items') as FormArray
}
模板
<form [formGroup]="orderForm">
<div formArrayName="items">
<div class="form-group" *ngFor="let item of items.controls; let i = index">
...
</div>
</div>
</form>