Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
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 Respostas
Responde à pergunta

0

Just set erros to null

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

about 4 years ago · Santiago Trujillo Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda