While building more complex reactive forms I stumbled across an issue while nesting reactiveFormGroups more than once.
So I've got two scenarios:
Form Component -> Form Partial Component -> Custom Input Component
Form Component -> Custom Input Component
The goal is to listen to the ngSubmit event in the custom input component to show its error state.
In my custom input component I'am injecting the ReactiveFormsDirective via the @Host() decorator. However if the component is nested as in scenario 1, it never receives any events.
My guess is that the problem in this scenario is related to "wrong" ControlContainer it tries to get a hold of. @Host() just looks up the injector chain until it reaches the host and not further. However this FormControlDirective doesn't know anything about the form submission.
If this was true, I'd try to pass the ControlContainer to the partial component to make it available to the input component.
viewProviders: [ { provide: ControlContainer, useExisting: FormGroupDirective } ]
Unfortunately, this doesn't work as expected.
To make this more tangible I've created a basic example here: https://stackblitz.com/edit/angular-7rmpvt
Would be great to get some help here on why this behaves the way it does and how to create a nice solution.