feat(router): Allow loadChildren to return a Route array#45700
Closed
atscott wants to merge 1 commit intoangular:masterfrom
Closed
feat(router): Allow loadChildren to return a Route array#45700atscott wants to merge 1 commit intoangular:masterfrom
atscott wants to merge 1 commit intoangular:masterfrom
Conversation
5a0cf43 to
37dd312
Compare
8005af8 to
ea2aef2
Compare
ea2aef2 to
b6ada11
Compare
jessicajaniuk
approved these changes
Apr 21, 2022
Contributor
jessicajaniuk
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
b6ada11 to
d826217
Compare
alxhub
approved these changes
Apr 21, 2022
Member
alxhub
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api, fw-core, fw-router
AndrewKushnir
approved these changes
Apr 22, 2022
Contributor
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
This commit expands the `LoadChildrenCallback` to accept returning `Routes`
in addition to the existing `NgModule` type. In addition, it adds a
check to ensure these loaded routes all use standalone components.
The components must be standalone because if they were not,
we would not have the required `NgModule` which the component is declared in.
Existing API:
```
{path: 'lazy/route', loadChildren: import('./lazy').then(m => m.LazyModule)}
@NgModule({
imports: [
ExtraCmpModule,
RouterModule.forChild([
{path: 'extra/route', component: ExtraCmp},
]),
],
})
export class LazyModule {}
```
The new API for lazy loading route configs with standalone components
(no NgModule) is to expand `loadChildren` to allow returning simply a `Routes` array.
```
// parent.ts
{
path: 'parent',
loadChildren: () => import('./children').then(m => m.ROUTES),
}
// children.ts
export const ROUTES: Route[] = [
{path: 'child', component: ChildCmp},
];
```
Note that this includes minimal documentation updates. We need to
include a holistic update to the documentation for standalone components
in the future that includes this feature.
d826217 to
374852c
Compare
Contributor
Author
|
merge assistance: requires an update to the g3 patch: http://cl/443671599 |
Contributor
Author
|
This PR was merged into the repository by commit 4962a4a. |
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit expands the
LoadChildrenCallbackto accept returningRoutesin addition to the existing
NgModuletype. In addition, it adds acheck to ensure these loaded routes all use standalone components.
The components must be standalone because if they were not,
we would not have the required
NgModulewhich the component is declared in.Existing API:
The new API for lazy loading route configs with standalone components
(no NgModule) is to expand
loadChildrento allow returning simply aRoutesarray.Note that this includes minimal documentation updates. We need to
include a holistic update to the documentation for standalone components
in the future that includes this feature.