How use correct markAsDirty on Angular

Viewed 896
1 Answers

You need to set option param for reset method, like: form2.get('id2').reset(null, {onlySelf: true});

The onlySelf option applies the reset() only to that control, not its parent.

Its default value is false and that's the reason why your form is marked as pristine after the reset of the id2 form control.

You can check the official angular website: https://angular.io/api/forms/FormControl#reset

Related