I have following app-routing.module.ts:
{
path: 'discover',
loadChildren: () => import('./components/platform/user-profile/platform.module').then(m => m.PlatformModule)
},
{
path: ':userRoute',
loadChildren: () => import('./components/platform/user-profile/platform.module').then(m => m.PlatformModule)
},
My goal is that /discover should open DiscoverPageComponent from PlatformModule
/userName1 should open UserPageComponent from PlatformModule
My platform-routing.module.ts contains following:
{
path: '',
component: UserProfileComponent,
},
{
path: 'discover',
component: DiscoverPageComponent,
},
This doesn't work as /discover will always open the UserProfileComponent instead of the DiscoverPageComponent. I can only open the DiscoverPageComponent from /userName1/discover
How can I have those two different routes open their specific component from the same lazy loaded module?
Stackblitz: https://stackblitz.com/edit/angular-w3rc5g Please see /discover and /anyUserName1
UserProfileComponentwithDiscoverPageComponentandDiscoverPageComponentwithUserProfileComponent. now/discoverwith openDiscoverPageComponentchildren: [ { path: ' ', component: UserProfileComponent }, { path: 'DiscoverPageComponent ', component: DiscoverPageComponent }, ]this setup will work.