How do you update specific properties of a form model?

You can use patchValue() method to update specific properties defined in the form model. For example,you can update the name and street of certain profile on click of the update button as shown below.

updateProfile() {
this.userProfile.patchValue({
firstName: 'John',
address: {
street: '98 Crescent Street'
}
});
}
<button (click)="updateProfile()">Update Profile</button>

You can also use setValue method to update properties.

Note: Remember to update the properties against the exact model structure.


May 08, 2022
187