我有 3 个级别的路由:app.module
> admin.module
> manage-users.module
。
出于某种原因,匹配的 URL 路径''
重定向到''
路径 inmanage-users.module
而不是HomeComponent
.
我的 app.routing 中有以下路线:
export const ROUTES: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent
},
{
path: 'admin',
loadChildren: './admin/admin.module#AdminModule'
{
path: 'details',
loadChildren: './details/details.module#DetailsModule'
},
{
path: 'search',
loadChildren: './search/search.module#SearchModule'
},
{
path: 'contact',
loadChildren: './contact/contact.module#ContactModule'
},
];
@NgModule({
imports: [
RouterModule.forRoot(
ROUTES,
{ enableTracing: true, useHash: true, preloadingStrategy: NoPreloading } // <-- debugging purposes only
)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
我的管理员路由:
const adminRoutes: Routes = [
{
path: 'admin',
component: AdminComponent,
children: [
{
path: '',
canActivateChild: [ AdminGuard ],
children: [
{ path: 'users',
loadChildren: './manage-users/manage-users.module#ManageUsersModule'
},
{
path: '',
component: AdminDashboardComponent
}
]
},
],
canActivate: [ AdminGuard ]
},
];
@NgModule({
imports: [ RouterModule.forChild(adminRoutes) ],
exports: [ RouterModule ]
})
export class AdminRoutingModule {
}
我的管理用户路由:
const manageUsersRoutes: Routes = [
{
path: '',
component: ManageUsersComponent,
}
];
@NgModule({
imports: [ RouterModule.forChild(manageUsersRoutes) ],
exports: [ RouterModule ]
})
export class ManageUsersRoutingModule {
}