如何 pdsadsadas

How to pdsadsadas

我需要修补 formArray 中的值 我首先得到所有值

.value 为您提供数组中控件的原始值。所以当你这样做时

const item = control.value.filter((valueForm:any) => valueForm.placeId === pin.oldValue.pointId);

您实际上是将 item 设置为值数组,而不是 FormControls。但是,.patchValue 是 FormControl 的 属性。您可以使用 .controls 属性 (documentation) 来获得您想要的匹配 control/controls。它看起来像下面这样(我重命名了一些变量以使其更清楚):

const arr = this.addressPoiForm.get("tableRows") as FormArray;
const matchingControls = arr.controls.filter((control: FormControl) => control.value.placeId === pin.oldValue.pointId);
matchingControls[0].patchValue({...});