我在路由中遇到一些错误" error: Cannot match any routes: 'Report/2000015'"。我使用RC4版本当我点击左边的菜单,比如"Group1",然后点击子菜单,比如"CCA ECPOS",我得到了上面的错误信息。我在活塞中重复了这个问题http://plnkr.co/edit/ycXbUv2KenXOVPb8862g?p=preview
我的路由配置如下
path: 'Home',
component: Home,
children: [
{ path: 'ReportGroupList', component: ReportGroupList },
{ path: 'ReportList/:group', component: ReportList },
{ path: 'Report/:reportID', component: Report },
柱塞在ReportList onSelect()方法上显示了一些错误。
首先,你把relativeTo指向一个不存在的对象。在这个组件上,激活的路由被命名为_ActivatedRoute
,您称它为route
。
第二件事是你的相对路径是错误的。定义的路径为/Home/Report/:reportID
。您导航到/Home/ReportGroupList
,然后导航到/Home/ReportList/Group1
。然后做一个像../Report/reportID
这样的相对路径,它被转换成/Home/ReportList/Report/reportID
。你需要第二个"相对向上",所以链接将是../../Report
。
所以onSelect的例子看起来像:
onSelect(rptId)
{
this._router.navigate(['../../Report', rptId], { relativeTo: this._ActivatedRoute });
}