我在从表单中获取 ID 时遇到问题。
this.myForm 看起来像这样 @Input() public myForm: FormGroup;
它是来自另一个 .ts 文件的输入
这是表单的结构:
myForm
- firstname
- lastname
- Email
--Tags (FormArray)
---id (FormGroup)
我想访问 id 并用一个用户的所有标签填充 this.selectedTagList ,这就是我想要做的:
const control: FormArray = <FormArray>this.myForm.controls[ 'tags' ];
control.controls.forEach(tag=> {
this.selectedTagList.push(this.tagList.find(tag.value.id));
});
如果我 console.log(this.myForm) 我得到这个结构:

console.log(control.controls), 'controls' 来自上面的代码:

但是当我执行 console.log(control.controls.length) 时,我得到 0。或者当我执行 console.log(control.controls[0]) 时,我得到未定义。
我不知道 FormGroup 对象去了哪里,也不知道为什么它说 Array[0] 里面有 4 个 FormGroup 对象。