Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
When you use ngModel in a child component, it fails to register itself to a NgForm that is held by a parent component.
This causes validation fail or success in the NgModel to bubble up to the NGForm, leaving the NgForm in a different state as the contents inside of it.
Please provide a link to a minimal reproduction of the bug
StackBlitz
Anything else?
The problem seems to come from using @Host when injecting ControlContainer into ngModel.
You can see it in this line. The @Host will limit it to the component it is in, instead of "bubbling up" to where the form is.
Also [ngModelGroup] seems to have the same issue. At least it is using @Host() in similar way code line
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
When you use ngModel in a child component, it fails to register itself to a NgForm that is held by a parent component.
This causes validation fail or success in the NgModel to bubble up to the NGForm, leaving the NgForm in a different state as the contents inside of it.
Please provide a link to a minimal reproduction of the bug
StackBlitz
Anything else?
The problem seems to come from using
@Hostwhen injectingControlContainerinto ngModel.You can see it in this line. The
@Hostwill limit it to the component it is in, instead of "bubbling up" to where the form is.Also
[ngModelGroup]seems to have the same issue. At least it is using@Host()in similar way code line