我有这个表格:
public profileSettingsGroup = new FormGroup({
firstName: new FormControl('Jonathon', Validators.required)
})
Run Code Online (Sandbox Code Playgroud)
我有这个方法:
setControlValue(control: string, value: string){
this.profileSettingsGroup.patchValue({
control: value
});
}
Run Code Online (Sandbox Code Playgroud)
我有这张地图:
for (let control in this.profileSettingsGroup.controls) {
this.map.set(control, this.camelCase(control));
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试通过变量更新表单中的控件,但 angular 似乎不允许我动态命名表单控件。它以control实际控件命名:“控件”。我可以在 angular 中做我想做的事吗?