我在FormGroup中有一个FormGroup和一个FormArray。
FormArray以正确的方式返回值和控件。但是当我尝试使用FormArray.value获取值时,它返回一个空数组。
console.log('child form here', this.services);
console.log('child form here', this.services['controls']);
哪里
get services(): FormArray {
return this.parentgroup.get('services') as FormArray;
}
发布于 2021-05-22 07:41:38
尽管名为FormArray,但它不是一个简单的数组,它是一个类。因此,为了访问控件数组,您应该使用以下语法:
var myControls = this.services.controls;
然后,您可以按索引从数组中获取任何控制对象:
var firstInput = myControls[0];
https://stackoverflow.com/questions/67642834
复制相似问题