Angular 无法读取属性';设置值';零角

Angular 无法读取属性';设置值';零角,angular,typescript,Angular,Typescript,需要在fileInfo中设置值 我的代码: 此.welderCreationForm.controls['wpsQualified'].value[index]['fileInfo'].setValue(data.\u id) 表单控制: fileInfo是一种formControl类型,但您将其用作常用的对象属性,这意味着它没有setValue方法。以下是一些帮助: const formArray = this.welderCreationForm.get('wpsQualified') a

需要在fileInfo中设置值

我的代码: 此.welderCreationForm.controls['wpsQualified'].value[index]['fileInfo'].setValue(data.\u id)

表单控制:
fileInfo
是一种
formControl
类型,但您将其用作常用的对象属性,这意味着它没有
setValue
方法。以下是一些帮助:

 const formArray = this.welderCreationForm.get('wpsQualified') as FormArray;
 formArray.at(index).setValue({fileInfo: data._id });

您需要按照以下方式编写:

(<FormGroup>(<FormArray>this.welderCreationForm.controls['wpsQualified']).at(index)).controls['fileInfo'].setValue(data._id);
((this.welderCreationForm.controls['wpsQualified'])).at(index)).controls['fileInfo'].setValue(data.\u id);

谢谢。但getting error“error error:必须为名为“wpsQualified”的窗体控件提供一个值是的,因为setValue方法强制更改所有其他表单控件值以忽略此更改setValue to patchValue以仅更新单个formControlpatchValue,因此我预期会出现相同的错误。请将答案标记为有用,如果它对您有效。谢谢:)