New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngModel complains when used with @defer #55028
Comments
Okay thanks. And just out of curiosity, is it a bad practice to have a component using ngModel for just one two-way binding without using ngModelOptions? It never occurred to me so I was not doing it but now that I'm facing this issue, I'm wondering whether I should start using ngModelOptions in these cases. |
Quick update: I've confirmed that the root cause of this issue is the same as the one from #54864. We are working on a fix and will keep this thread updated once the fix is available.
If you do not rely on that
The issue was caused by the bug in Angular's code, adding |
…ocks This commit updates the `@defer` logic to establish proper injector resolution order. More specifically: - Makes node injectors to be inspected first, similar to how it happens when `@defer` block is not used. - Adds extra handling for the Router's `OutletInjector`, until we replace it with an `EnvironmentInjector`. Resolves angular#54864. Resolves angular#55028. Resolves angular#55036.
…ocks (#55079) This commit updates the `@defer` logic to establish proper injector resolution order. More specifically: - Makes node injectors to be inspected first, similar to how it happens when `@defer` block is not used. - Adds extra handling for the Router's `OutletInjector`, until we replace it with an `EnvironmentInjector`. Resolves #54864. Resolves #55028. Resolves #55036. PR Close #55079
Quick update: the fix for this issue was merged and released as a part of Angular v17.3.2 (available on NPM). Please let us know if you still see the issue after updating to v17.3.2. |
I already updated my code to use ngModelOptions, however, I tried this version on the failing stackblitz and I can reproduce the issue so I guess it is correctly fixed :-) Thanks for the quick action. |
…ocks (angular#55079) This commit updates the `@defer` logic to establish proper injector resolution order. More specifically: - Makes node injectors to be inspected first, similar to how it happens when `@defer` block is not used. - Adds extra handling for the Router's `OutletInjector`, until we replace it with an `EnvironmentInjector`. Resolves angular#54864. Resolves angular#55028. Resolves angular#55036. PR Close angular#55079
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
Say we have a component with a form.
One of the field is a cutstom component implementing ControlValueAccessor.
This component uses ngModel without ngModelOptions (which might be a bad practice, but it works).
When the component hosting the form is used without @defer, it works as expected, but as soon as it is used in a @defer block, the error "ngModel cannot be used to register form controls with a parent formGroup directive." is thrown.
I'm not sure whether it's a bad practice or not to use ngModel without ngModelOptions in that scenario but I think the behavior should be consistent whether you use @defer or not. Either it should fail every time or works every time.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/angular-17-starter-project-egsglm
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: