How to associate a FormGroup object with a ModelClass object

On button "I want to send and send the student object", so pls tell me how to associate the groupGroup object with the ModelClass object. Do not want to manually add data one by one to the variable. I need to bind one path not manually.

This is my groupGroup object

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) ])

        });

This is my model

class Student 
{        
    public Name: string="";
    public Code: string="";
    public Äddress: string="";

} 
+4
source share
1 answer

When you click a button, you can do the following:

onClick(){
  let student = new Student();
  student = this.AMform.value;
}
+2
source

Source: https://habr.com/ru/post/1657980/


All Articles