导航辅助路由会引发异常

时间:2016-12-08 13:37:13

标签: angular angular2-routing

鉴于此路由配置:

export const ROUTES: Route[] = [
      { path: '', redirectTo: 'projects', pathMatch: 'full' },
      { path: 'projects', component: ProjectsComponent,
        children: [
          { path: 'projectlist', component: ProjectListComponent, outlet: 'sidemenu' }
        ]
      }
    ];

致电

this.router.navigate(['projects(sidemenu:projectlist)']);

引发

  

error_handler.js:47 EXCEPTION:未捕获(在承诺中):错误:不能   匹配任何路线。网址细分:'项目(sidemenu%3Aprojectlist)'

1 个答案:

答案 0 :(得分:0)

此设置有效。更清洁,但不确定是否传统。

export const ROUTES: Route[] = [
  { path: '', redirectTo: 'projects', pathMatch: 'full' },
  { path: 'projects',
    children: [
      { path: '', component: ProjectsComponent },
      { path: '', component: ProjectListComponent, outlet: 'sidemenu' }
    ]
  }
];