manfredsteyer / multi-framework-micro-frontend

77 stars 36 forks source link

Nested RouteModule forChild calls #8

Open billy-briggs-dev opened 2 years ago

billy-briggs-dev commented 2 years ago

I have situation where I am trying to chain a bunch of lazy-loaded routes with the forChild function. However after loading one of my lazy loaded modules, I get this route error in the browser when clicking on a link to a supposedly newly registered route:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'mfe3/b/c' Error: Cannot match any routes. URL Segment: 'mfe3/b/c'

This is the structure of my RouterModule reference calls in each module.

AppModule

RouterModule.forRoot([
    { matcher: endsWith('a'), component: AComponent },
    { matcher: endsWith('b'), loadChildren: () => import('./b/b.module').then(m => m.BModule)}
], { relativeLinkResolution: 'legacy' })

BModule

RouterModule.forChild([
  { matcher: endsWith(''), component: BComponent },
  { matcher: endsWith('c'),  loadChildren: () => import('./c/c.module').then(m => m.CModule)},
])

CModule

RouterModule.forChild([
    { matcher: endsWith(''), component: CComponent },
])

Is there a reason for why the CModule matcher isn't being registered in the Router? Any insight would really help me out!