1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

this.form.controls['user'].addControl is not a function

Discussão em 'Angular' iniciado por user3892, Outubro 13, 2024 às 00:43.

  1. user3892

    user3892 Guest

    I am trying to add a new control to my FormGroup but I get the error: this.form.controls['user'].addControl is not a function.

    Here is my code:

    this.form.addControl('user', new FormGroup([]));
    (<FormGroup>this.form.controls['user']).addControl(
    'john', this.formBuilder.control(''),{ emitEvent: false }
    );


    When I check this.form.controls['user'] instanceof FormGroup I get false!

    I am using the same principle in another component, and there I get no error. Also this code was working on angular 16, and after upgrading to angular 18, I see this error.

    Does anyone have any idea what can be the problem and how can be solved? Thank you in advance!

    Continue reading...

Compartilhe esta Página