angular2无法相对于父路线导航

我使用angular2 cli.

测试导航相对遇到的问题:

路由配置:

{
    path: '',
    component: CheckCompanyComponent,
    children:[
      {
        path:'',
        loadChildren: 'app/components/company/check-company-home/check-company-home.module#CheckCompanyHomeModule'
      },
      {
        path:':id',
        loadChildren: 'app/components/company/check-company-detail/check-company-detail.module#CheckCompanyDetailModule'
      }
    ]
  }

在check-company-home组件中

goIdPage(){
    this.router.navigate(['22'], { relativeTo: this.route });
  }

can navigate from “/company” to “/company/22”

在check-company-detail组件中:

goBack(){
    this.router.navigate(['../'], { relativeTo: this.route });
  }

But can’t navigate form “/company/22” to “/company”,

为什么?

最佳答案 只用一个点试试吧:

goBack(){
    this.router.navigate(['./'], { relativeTo: this.route });
}
点赞