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

617
Visualizações
setValue() and patchValue() method is not working in Angular

I'm developing a contact change form for my application using FormGroup and FormControl with Angular 8. I set up several fields that are filled in advance if the information is already filled in for the contact. So I used this method several times to be able to set up the fields of my form: create several FormControls, push them into a FormControl array which will then be placed in a FormGroup. Everything works well except for one, the value always remains a null, even the method setValue() and patchValue() does not work.

Method used in general for all fields:

const controls = {};                
let control = new FormControl({
    value: fieldToValue(this.values, field.key, field, true),
    disabled: this.locked
});
controls[this.prefix + field.key] = control;
this.group = new FormGroup(controls); 

I tried this too but it doesn't work:

let value = '2';
control = new FormControl();
control.setValue(value);

result

Do you know what is preventing my FormControl from setting its value ?

about 4 years ago · Santiago Trujillo
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