小编jul*_*uli的帖子

具有多个命名出口的延迟加载模块上的Angular2路由

我在Angular2中遇到了路由问题.

  1. 我的模块是懒惰的(但到目前为止基本的"loadChildren"方法没有问题)
  2. 正在加载模块本身(在dev-tools的网络选项卡中可以看到)

我的问题:

请参阅下面的路由代码.第一个版本正常工作.找到路由,并且在创建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)

angular2-routing angular

5
推荐指数
1
解决办法
5659
查看次数

标签 统计

angular ×1

angular2-routing ×1