I'm encountering an issue while trying to lazy load module according to the user profile, I defined three default paths (with empty path for each route) and each user has access to a specific module, i'm using a guards in order to detemine the current user profile (actually i'm toggling manually to set the default loaded module by setting const canGo =true)
The expected behavior is that the actual routing configuration should activate the adequate route according to the profile but that's not the case.
export const routes: Routes = [
{
path: '',
loadChildren: 'app/user/user.module#UserModule',
canActivate: [
CanActivateUserModuleGuard
],
},
{
path: '',
loadChildren: 'app/admin/admin.module#AdminModule',
canActivate: [
CanActivateAdminModuleGuard
]
},
{
path: '',
loadChildren: 'app/moderator/moderator.module#ModeratorModule',
canActivate: [
CanActivateModeratorModuleGuard
]
},
{
path: '404',
component: NotFoundComponent
}
];
NB: below the online issue if interested https://stackblitz.com/edit/angular-vd4oyu?file=app%2Fapp-routing.module.ts
What is the best way to accomplish this requirement?