1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How do you listen to disabled form control changes?

Discussão em 'Angular' iniciado por bestfirstsearch, Junho 13, 2025.

  1. I have 2 form control text fields, one visible and the other disabled. Based on the value of the disabled field, I want to toggle buttons on visible text field. The value of the disabled field can be changed somewhere else in the app using formGroup.patchValue(). From the visible text field, I'm listening to the hidden field with valueChanges to know when to turn on the buttons.

    The problem is that the visible text field isn't picking up changes from the disabled field. Is there a way for me to listen to disabled form controls or is this an entirely different problem that I'm not understanding?

    // from the visible text field
    this.formGroup.controls[hiddenField].valueChanges()
    .pipe(
    map((fgData) => {
    return this.formGroup.getRawValue()[hiddenField]; // get disabled field val
    }),
    distinctUntilChanged()
    ).subscribe((value) => {
    this.toggleButtons(value);
    });

    Continue reading...

Compartilhe esta Página