У меня есть 2 разных набора маршрутов, и в зависимости от URL, мне нужно загрузить маршруты и перенаправления.
export const general_routes: Routes = [
{
path: '',
children: [
{ path: 'login', component: LoginComponent },
{ path:'',redirectTo:'home',pathMatch:'full',canActivate :[AuthGuard]},
{ path: 'home', component: WorkbenchhomeComponent, canActivate: [AuthGuard]
},
]
}
];
export const tool_routes: Routes = [
{
path: '',
children: [
{ path: 'toolHome', component: ToolSuiteComponent },
{ path:'',redirectTo:'toolHome',pathMatch:'full'}
]
}
];
@NgModule({
imports: [ RouterModule.forRoot((window.location.href.includes('tool'))?tool_routes:general_routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
"RouterModule.for Root ((window.location.href.includes ('tool')) "всегда оценивается как true, и tool_routes загружается. Когда я пытаюсь нажать на URL без" tool ", он не загружает общие маршруты и пытается найти" home "в tool_routes.