【发布时间】:2017-01-05 23:26:12
【问题描述】:
路由器详情:
这是一个特性模块的路由细节,被延迟加载。 路线是 /customers
const routes: Routes = [
{ path: '',
component: CustomersComponent,
children: [
{ path: '', component: CustomersListComponent },
{ path: ':id', component: CustomersDetailsComponent,
resolve: {
xxx: CustomerResolve1
}
,children: [
{ path: ':module', component: CustomersModuleDetailsComponent,
resolve: {
xxx: CustomerResolve2
}
}
] }
]
}
];
在 2 个解析器中,我只是写信给我已经到达解析器的控制台。
如果我输入以下网址:
http://localhost:4200/customers/45/invoices
执行 2 个解析器。
如果我按下在我的 ts 中执行以下操作的按钮:
this.router.navigate(['customers','100','invoices']);
只执行第一个解析器!
作为我最里面的组件“CustomersModuleDetailsComponent”显示信息 基于 url,它不会被刷新,因为该组件的解析器没有被执行。
有什么建议吗? (除了将解析器更改为警卫) (除了通过@input或eventEmitter将id从父组件传输到子组件)
谢谢
【问题讨论】:
-
你应该使用绝对路径名
-
@RomanC 你能解释一下吗?
-
老兄,你应该把这个添加到你的路由器配置中:)
-
@RomanC 如何使用延迟加载模块来做到这一点?上述路线属于功能模块。 “/customers”路径在 app.module.routing.ts 中定义