how to update an object with reactive forms in angular code example
Example 1: update formgroup value angular
To set all FormGroup values use, setValue:
this.myFormGroup.setValue({
formControlName1: myValue1,
formControlName2: myValue2
});
To set only some values, use patchValue:
this.myFormGroup.patchValue({
formControlName1: myValue1,
});
Example 2: get formcontrol value
this.loginForm = new FormGroup({
'email': new FormControl('', { validators: [Validators.required] })
});
const { email } = this.loginForm.value;