angular2 router dose not work when “loadChildren” loading modules
See original GitHub issueI have a router definition like this:
const routes: Routes = [
{
"path": "member",
"loadChildren": "app/member/member.module#MemberModule"
},
{
"path": "",
"loadChildren": "app/video/video.module#VideoModule"
},
{
"path": "**",
"redirectTo": ""
}
]
MemberRouter definition like this:
const routes: Routes = [
{
"path": "order",
"component": MemberComponent,
"loadChildren": "app/member/order/order.module#OrderModule"
},
{
"path": "",
"component": MemberComponent,
"loadChildren": "app/member/index/index.module#IndexModule"
}
]
OrderRouter definition like this:
const routes: Routes = [
{
"path": "list",
"outlet": "member",
"component": OrderComponent,
"loadChildren": "app/member/order/list/list.module#ListModule"
},
{
"path": "",
"outlet": "member",
"component": OrderComponent
}
]`
ListRouter definition like this:
`const routes: Routes = [
{
"path": "",
"outlet": "order",
"component": ListComponent
}
]
It dose not work at “/member/order/list”
It is working at “/member/order”
“OrderRouter” rules can not be matched when “MemberRouter” is lazy loaded
“loadChildren” dose not work when nested
Please help me solve, thank you!
Plunker Demo Click “product/detail/item” button dose no work.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:19 (3 by maintainers)
Top Results From Across the Web
Angular 12 Routing doesn't work when lazy loading modules
app-routing const routes: Routes = [ { path: 'login', loadChildren: () => import('./login/login.module').then((c) => c.
Read more >Lazy-loading feature modules - Angular
To lazy load Angular modules, use loadChildren (instead of component ) in your AppRoutingModule routes configuration as follows. AppRoutingModule (excerpt)
Read more >Manually Lazy Load Modules And Components In Angular
A lazy-loaded module can be defined in the routing configuration using the new import(...) syntax for loadChildren : @NgModule({ imports: [ RouterModule.
Read more >How To Use Lazy Loading Routes in Angular | DigitalOcean
Step 1 – Setting Up the Project · Step 2 – Using loadChildren · Step 3 – Setting Route Configuration in the Feature...
Read more >Lazy Loading a Module - Rangle.io : Angular Training
With lazy loading our application does not need to load everything at once, it only needs to ... We use the property loadChildren...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve fixed the issue…you just add ‘:’ before the ‘" in path value like ':’… example like { path: ‘😗*’, loadChildren: ‘app/components/pagenotfound/pagenotfound.module#PagenotfoundComponentModule’, “pathMatch”: “full” }
For me, I also get same error and I’ve fixed it 😃
only add ./ before which modules want to link at root module app!
I hope solved your problem 👍