You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ROUTES provider in a standalone lazy-loaded component not providing routes #54518
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
Using a provider in the ngModule seems to work fine - the routes in the provider are available.
Converting the component into a standalone component, the same provider no longer functions. The factory isn't even called. Same for when I use route providers.
The fact that the factory is not called seems to indicate that the token was never consumed. Or was consumed before the component initialized? I also cannot use inject() directly in loadChildren as it is not supported.
This is working as expected. Routes need to be provided in the environment injector tree. Putting it in the component providers makes it available to the component but not services provided in root.
Activity
atscott commentedon Feb 20, 2024
This is working as expected. Routes need to be provided in the environment injector tree. Putting it in the component providers makes it available to the component but not services provided in root.
When migrating form loadChildren that uses modules, you should update your lazy children to just be a dynamic import of the routes array directly. It does not need to be provided anywhere at all. https://angular.io/guide/standalone-components#lazy-loading-many-routes-at-once
atscott commentedon Feb 20, 2024
If your routes are dynamic and you do need that factory then I think what you’re looking for is this #51532
angular-automatic-lock-bot commentedon Mar 22, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.