angulartypescriptangular-material

How to remove specific errors in Angular Form Group


Currently I'm trying to create a dynamic validation in Angular Forms and I found this Question.

Adding the error to the field

this.form.get('field').setErrors({ 'invalid': true });

Removing the error to the field

this.form.get('field').setErrors(null);

My question is how can I remove a specific error in the field? Example I have multiple setErrors and I only want to remove the invalid error


Solution

  • I believe this should work:

    this.form.get('field').setError({'invalid': null})