Tech Blog

Angular patchValue vs setValue

By: Chris Dunn on Tue Dec 4, 2018 (2 min read)

When creating model driven forms in Angular, for CRUD operations, you will need to map a data model to the FormGroup.  You can do this by manually setting each control value or you can use a function to map the entire data model to the FormGroup model.  At first glance of the documentation it looks like a good option would be setValue on the FormGroup object. myForm.setValue(formData, {onlySelf: true}); This will work if you have a matching control in the Form Group model (control name) for eac ...

Copyright 2019 Cidean, LLC. All rights reserved.

Proudly running Umbraco 7. This site is responsive with the help of Foundation 5.