Javascript 如何使用动态表单控件名称修补表单值

Javascript 如何使用动态表单控件名称修补表单值,javascript,angular,Javascript,Angular,我有以下表格: public profileSettingsGroup = new FormGroup({ firstName: new FormControl('Jonathon', Validators.required) }) 我有这个方法: setControlValue(control: string, value: string){ this.profileSettingsGroup.patchValue({ control: value }); } 我有

我有以下表格:

public profileSettingsGroup = new FormGroup({
    firstName: new FormControl('Jonathon', Validators.required)
})
我有这个方法:

setControlValue(control: string, value: string){
  this.profileSettingsGroup.patchValue({
    control: value
  });
}
我有这张地图:

for (let control in this.profileSettingsGroup.controls) {
  this.map.set(control, this.camelCase(control));
}

我试图通过变量更新表单中的控件,但angular似乎不允许我动态命名表单控件。它将
control
作为名为“control”的实际控件。我能在角度上做我想做的吗?

你需要在控件周围用括号括起来。看


在控件周围需要括号。看

setControlValue(control: string, value: string){
  this.profileSettingsGroup.patchValue({
    [control]: value
  });
}