Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
How to clear errors in angular controls

It's really clear how to set custom errors in angular:

this.form.controls['field'].setErrors({same:true});

But it is not clear on how to remove that. Anyone know how to do this? Any alternatives?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Just set erros to null

this.form.controls['field'].setErrors(null);

about 4 years ago · Santiago Trujillo Report

0

this.form.controls['field'].updateValueAndValidity();

this is the method documentation:

/**
  * Re-calculates the value and validation status of the control.
  *
  * By default, it will also update the value and validity of its 
 ancestors.
  */
 updateValueAndValidity({onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}):  void {... }
about 4 years ago · Santiago Trujillo Report

0

You can use the following when you want to remove the custom error:

delete this.form.controls['field'].errors['same']

you might need/want to update the validity after this with:

this.form.controls['field'].updateValueAndValidity();
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!