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

Angular valueChange subscription affects other components unintentionally

Discussão em 'Angular' iniciado por RK234, Maio 30, 2025.

  1. RK234

    RK234 Guest

    I have this code:

    this.fg.controls[this.dependency.field].valueChanges.subscribe(
    (value) => {
    console.log(value)
    this._checkDependency(value);
    }
    );


    this.fg is essentially an UntypedFormGroup. The intention is to change the visibility of a field depending on the value of another. Now i have one of these formGroups in a component, and another similar in a different component opening in a modal on top of the first. Upon change of the dependency field, the log occurs and the visibility changes as intended.

    How can it be, that a similar field with the same name in the parent component changes visibility too synchronously, wihtout emitting a log? What kind of angular magic can this be, when there's no connection between the component via input or output vars and nothing similar?

    Continue reading...

Compartilhe esta Página