我在Angular 5中创建了一个嵌套表单组。这是它的外观:
但是在遍历子表单组的表单控件时,出现以下错误:
ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
<div
*ngFor = "let parentControl of parentGroup.controls"
[formGroupName]="xyz">
<custom-component
*ngFor="let childControl of parentControl.controls['conditions'].controls">
Hello
</custom-component>
</div>
即使我尝试了以下操作:
<div
*ngFor="let parentControl of parentGroup.controls
[formGroupName]="xyz">
<custom-component
*ngFor="let childControl of parentControl.get('conditions').controls">
Hello
</custom-component>
</div>
所以我想遍历formgroup
“条件”内的所有表单控件。
有人可以让我知道我在这里错过了什么吗?