Angular setValue, patchValue

Angular setValue
Sets the value of the Form Group. It accepts an object that matches the structure of the group, with control names as keys.

Set the complete value for the form group
const form = new FormGroup({
  first: new FormControl(),
  last: new FormControl()
});
console.log(form.value); // {first: null, last: null}
form.setValue({first: 'Nancy', last: 'Drew'});
console.log(form.value); // {first: 'Nancy', last: 'Drew'}
Continue reading “Angular setValue, patchValue”