Angular 2 Router - Named outlets

好久不见. 提交于 2019-12-01 04:07:06

Try this configuration:

{
    path: 'wrap',
    component: HomeComponent,
    children: [
        {
            path: 'dash',
            component: DashboardComponent,
            outlet: 'dashboard'
        }
    ]
}

with:

this.router.navigateByUrl('/wrap(dashboard:dash)');

I don't know why needs an url fragment (like the "wrap" I added) but it works...

and the others:

{
    path: 'blog',
    component: HomeComponent,
    outlet: 'main'
},
{
    path: 'blog',
    component: RegisterComponent,
    outlet: 'dashboard'
}

with:

this.router.navigateByUrl('/(main:blog)');
this.router.navigateByUrl('/(dashboard:blog)');

This is what I ended up using to get it to work:

       this.router.navigate([{ outlets: { detail: ['summary'] } }], 
                            { skipLocationChange: true, relativeTo: this.route });

Note: I don't have a '' for my parent path. There seem to be a number of github issues related to '' as a parent path but not sure if they apply.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!