首页 > 解决方案 > 如何修复“将值转换为类型时出错”

问题描述

我创建了一个动态表,可以添加行并通过输入和选择编辑所有行。要将新表数据发布到我的 web api 中,我使用 FormArray,如下所示:

public kommunikationseintraeges: FormArray = new FormArray([])

//My Form with also other data:
persoForm = new FormGroup({
...
kommunikationseinträges: this.kommunikationseintraeges,
..
})

//Thats how i push my already existing values into my table:
this.kType.forEach((singlekType:any) => {
          this.kommunikationseintraeges.push(new FormGroup({
        
            kommunikationsart: new FormControl(singlekType.kommunikationsart.bezeichnung),
            kommunikationsort: new FormControl(singlekType.kommunikationsort.bezeichnung),
            kommunikationsnummer: new FormControl(singlekType.nummerAdresse),
            })
          )
          

至少我像这样发布我的新数据:

onSubmit(){
      this.pService.updateUser(this.person.personId, this.persoForm.getRawValue()).subscribe();
  }

如您所见,我得到了没有任何数组的响应,但我试图用数组发布整个数据。我的数据如何来自我的数据库:

正常数据 然后错误如下所示:

错误

所以看来他目前无法处理我的阵列,但我不知道我应该如何修复它。

标签: .nettypescript

解决方案


推荐阅读