在按钮上单击我必须发布和发送学生对象, 所以请告诉我如何将 formGroup 对象绑定(bind)到 ModelClass 对象, 不想手动将数据一个一个地添加到变量中。 我必须以单一方式绑定(bind),而不是手动绑定(bind)。
这是我的 formGroup 对象
this.AMform = fb.group({
"Name": new FormControl("", [Validators.required, Validators.maxLength(10) ]),
"Code":new FormControl("", [Validators.required, Validators.maxLength(10) ]),
"Address": new FormControl("", [Validators.required, Validators.maxLength(10) ])
});
这是我的模型
class Student
{
public Name: string="";
public Code: string="";
public Äddress: string="";
}
最佳答案
点击按钮你可以做以下事情:
onClick(){
let student = new Student();
student = this.AMform.value;
}
关于angular - 如何将 FormGroup 对象绑定(bind)到 ModelClass 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40084699/