Getting "control.registerOnChange is not a function" after changing form
See original GitHub issueI’m submitting a … (check one with “x”)
[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
After patching a form of type FormArray
(form.patchValue(myArray);
) with FormGroup
items, [formGroup]='form'
in my html throws control.registerOnChange is not a function
. I patch it when I initialize my app and everything works fine but when I change the form with another FormArray
(I tried with the same array), I’m getting this error. After further investigation (and hours trying to understand what was going on), it seems that the error comes from line 1634 of forms.umd.js
when it does control.registerOnChange(function (newValue, emitModelEvent) {
.
When it works, control
(of control.registerOnChange
) is of form FormControl
while when it fails, it is of form FormGroup
. The problem is that my FormArray
is somewhat deep and the first time I patch it, it goes at the leaf of the branches to reach FormControl
while the second time it goes to the first branch which in my case is a FormGroup
.
The problem is that I don’t know why it doesn’t go to the leaf the second time. I use the same functions and methodology to patch the values and the FormArray
looks exactly the same in both cases!
Expected behavior
It should not throw any error…
Minimal reproduction of the problem with instructions
I couldn’t make a minimal demo but would definitely share the functions I use to create the form if needed.
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
NodeJS 7.4.0 running on Windows 10
-
Angular version: 2.4.7
-
Browser: Chrome 55 64bit
-
Language: Typescript
Issue Analytics
- State:
- Created 7 years ago
- Reactions:9
- Comments:38 (7 by maintainers)
This should have been fixed a long time ago 😦
I understand angular’s team has a lot to do but this is almost a one year old bug and I’m still having lots of troubles with it…
Almost 3 years and not a word from the Angular team!
It is a shame that the Angular community spends time to find bugs and work on solutions but the team doesn’t pay attention to that! What should I do to get it fixed in the next release?
I am currently working on a new project and have moved to React… I love Angular but if we can’t get the support we need after 3 years, it makes it unusable!