Answer the question
In order to leave comments, you need to log in
How do you load a model into a reactive form?
I load the data in the form on click of the button like this
editUser(user: User) : void {
this.user = user;
this.load(user);
$('#add-user').modal();
}
load(user: User) : void {
this.userForm.controls['firstName'].setValue(user.firstName);
this.userForm.controls['surname'].setValue(user.surname);
this.userForm.controls['email'].setValue(user.email);
this.userForm.controls['phone'].setValue(user.phone);
this.userForm.controls['role'].setValue(user.role);
this.userForm.controls['state'].setValue(user.state);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question