【发布时间】:2022-09-27 18:06:18
【问题描述】:
有什么方法可以从应用程序的路由配置访问功能模块路由配置。零件
我有一个延迟加载的功能模块。我想访问我的app.module 上的功能模块路由数据,以根据 URL 的子路径突出显示我的侧导航栏(KendoUI 抽屉)菜单项。例如,如果将http://localhost:4200/parent/child-component-name 传递到浏览器导航用户应该看到在侧导航栏中选择了child-component-name。
从 \'@angular/core\' 导入 { NgModule }; 从\'@angular/router\'导入{RouterModule};
------------ app.routing.module.ts --------------
const parentRoutes = [
{
path: \'\',
redirectTo: \'parent\',
pathMatch: \'full\',
},
{
path: \'parent\',
loadChildren: () =>
import(\'./modules/parent/parent.module\').then(
(m) => m.parent
),
},
];
------------ child.routing.module.ts --------------
const routes: Routes = [
{
path: \'\',
component:ParentViewComponent,
children:[
{
path:\'\',
component: FirstChildComponent,
},
{
path: \'second\',
component: SecondChildComponent,
},
{
path: \'third\',
component: ThirdChildComponent,
},
}
]
在我的 app.component.ts 中,我能够使用 this.router.config 访问父路由数据,但在 app.routing.module.ts 中只提供了两条路由。
标签: angular angular-routing angular-router