How to clear the errors on form control. I have a method that tries to clear the errors on the form control but in vain.
this.form.controls[ 'postalCode' ].setErrors(null);
The form control name is postalCode and when I set the error to null, it doesn't remove the error from that control.
To clear all the errors
this.form.get('postalCode').setErrors(null);
To clear by its key
this.form.get('postalCode').setErrors({key: null});
this.form.get('postalCode').updateValueAndValidity(); //may need this in child components
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With