Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

738
Vistas
enable/disable form control fires valueChanges Angular 2 Forms

Any ideas why when running the following code I get the valueChanges event of 'firstName' control fired?

let form: FormGroup = this.createForm();
form.controls['firstName'].enable();

form.controls['firstName'].valueChanges(value=>{
      //some code
});

As no value has changed (just the status), I wouldn't expect valueChanges to be triggered here, only the statusChanged.

Am I missing something?

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

No idea why it behaves as it does, but you can send emitEvent: false to enable/disable without firing valueChanges.

form.controls['firstName'].enable({ emitEvent: false });
about 4 years ago · Santiago Trujillo Denunciar

0

Basically complete form is mapped on a model, so whenever you enable/disable any control, the form model's property changes. And because the model is changing so valueChanges event will be triggered. I think its normal.

about 4 years ago · Santiago Trujillo Denunciar

0

I have angular version 6.0.3

this.form.get('inputName').setValue(newValue, {onlySelf: true, emitEvent: false});

This works for me.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda