We have taken the example from the previous tutorial in which we had a parent form group named "userprofileForm" and the nested form group named "address".
So if in case we have to access and update the controls which resides in the parent form group and nested form group in one go, then we can use the PatchValue method in Angular.
eg:
this.userprofileForm.patchValue({
firstName: 'Jimmy',
address: {
address1: 'ABC Appartment'
}
});
So here by using the PatchValue method, we are updating the "firstname" control of the "userprofileForm" group and "address1" control of the nested form group named "address" in One Go.
0 Comments