I am using Lazyloading
and I have two router-outlets
. the problem occurs when I want to navigate to another child route. I get this error,
TypeError: Cannot read property 'split' of undefined at defaultUrlMatcher (router.js:566) at match (router.js:2221) .....
My main app-router module looks like,
const appRoutes: Routes = [
{ path: '', redirectTo: 'web/welcome' , pathMatch: 'full' },
{ path: 'web', redirectTo: 'web/welcome' , pathMatch: 'full' },
{
path: 'web',
loadChildren: 'app/core/website/modules/website.module#WebSiteModule',
data: { preload: true }
},
{
path: 'dbapp', canActivate: [AuthGuardService],
loadChildren: 'app/core/database/modules/db.module#DbModule',
data: { preload: true }
},
{ path: '**', redirectTo: '/404', pathMatch: 'full'},
{ path: '**', component: NotFoundComponent, data: { message: 'We Could Not Serve Your Request!'}},
];
and for dbapp
I have this routing module,
const dbRoutes: Routes = [
{
path: '',
component: DbHomeComponent,
data: { preload: true },
pathMatch: 'full',
children: [
{ path: '', component: UserDashboardComponent },
{
path: 'registry',
canActivate: [RoleGuardService],
data: { expectedRole: { roles: ['reg'] } },
loadChildren:
'app/core/database/database-cores/registry-core/modules/registry.module#RegistryModule'
// canActivateChild: [RoleGuardService]
},
{
path: 'embryology',
canActivate: [RoleGuardService],
data: { expectedRole: { roles: ['emb'] } },
loadChildren:
'app/core/database/database-cores/embryology-core/modules/embryology-routing.module#EmbryologyRoutingModule'
},
{
path: 'nursing',
canActivate: [RoleGuardService],
data: { expectedRole: { roles: ['nur'] } },
loadChildren:
'app/core/database/database-cores/embryology-core/modules/embryology-routing.module#EmbryologyRoutingModule'
}
]
},
];
My map looks like the following,
Router Map, Underlined
components
are router-outlets
so according to my config. the routing starts at https://www.artngcore.com:4200/web/welcome
and after authentication the route changes to https://www.artngcore.com:4200/dbapp
I managed to navigate to UserDashboardComponent
as a default route, my problem if I do routing to the other children, i.e. routerLink="/dbapp/registry"
How can I show a child component as a default route and navigate to other children routes?