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

740
Views
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 answers
Answer question

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 Report

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 Report

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 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!