我有一条试图工作的嵌套路线。当我尝试像这样导航到嵌套路线时:
this.router.navigateByUrl('/project/' + this.project._id + '/shot/' + row._id);
它将浏览器中的路由更改为应有的样子。例如:
http://localhost:4200/project/5cdc30c20d86931b180de39b/shot/5cdc31170d86931b180de3b2
但是,ShotComponent永远不会被实例化!
app.routes.ts看起来像这样。
{
path: 'project',
children: [
{
path: '',
component: ProjectListComponent
},
{
path: ':_id',
component: ProjectComponent,
children: [
{
path: 'shot/:_id',
component: ShotComponent
}]
}]
}
如果我将射击路线设为非嵌套路线,则组件将正确实例化。我想我这里有问题。有任何想法吗?在控制台或角度cli中不会产生任何错误
答案 0 :(得分:0)
尝试为镜头ID添加其他名称
{
path: 'project',
children: [
{
path: '',
component: ProjectListComponent
},
{
path: ':_id',
component: ProjectComponent,
children: [
{
path: 'shot/:_shotid',
component: ShotComponent
}]
}]
}