What causes the “control.registerOnChange is not a function” error

后端 未结 10 2063
一向
一向 2020-12-01 20:39

I have a form using the reactive form approach. The form is created as follow in my pug:

form([formGroup]=\'form\', novalidate=\'\', (ngSubmit)=\'postSurvey(         


        
10条回答
  •  醉梦人生
    2020-12-01 21:07

    In my case this error was thrown because I was using FormControlName instead of FormArrayName to bind to a FormArray in my template.

    My component code:

    public form = new FormGroup({
       ...
       checkboxes: new FormArray([....])
    })
    

    My template code that threw error:

    
    

    Fix:

    
    

提交回复
热议问题