-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Description
I'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