我在Angular2中遇到了路由问题.
我的问题:
请参阅下面的路由代码.第一个版本正常工作.找到路由,并且在创建routerLink时不会抛出任何错误.
但是,为什么我的第一个摘录工作,第二个不?我不想创建一个伪路径"测试"只是为了让这个工作.第二个例子是获取此错误消息.
[...]无法匹配任何路线.网址细分:'mypath'[...]
工作路线:
children: export const routes: Routes = [
{
path: '',
component: ParentSplitViewComponent,
children: [
{
path: '',
redirectTo: 'test'
},
{
path: 'test',
component: SplitViewComponent,
children: [
{
path: '',
redirectTo: 'list'
},
{
path: 'list',
component: MyListComponent,
outlet: 'left'
},
{
path: ':id',
component: MyDetailComponent,
outlet: 'right'
}
]
}
]
}
];
Run Code Online (Sandbox Code Playgroud)
不工作路由:
children: export const routes: Routes = [
{
path: '',
component: ParentSplitViewComponent,
children: [
{
path: '', …Run Code Online (Sandbox Code Playgroud)