如何将命名出口导航到根路径

时间:2019-06-08 09:30:34

标签: angular angular7 angular-routing angular7-router

我在手动导航到根(默认)路由时遇到麻烦:

private router: Router,

//this works
this.router.navigate([{ outlets: { myoutlet: ['path2'] } }], {})

//this does not work
this.router.navigate([{ outlets: { myoutlet: [''] } }], {})

路由的定义如下:

const routes: Routes = [
  { path: '', component: Component1, outlet: "myoutlet", pathMatch: 'full' },
  { path: 'activities', component: Component2, outlet: "myoutlet" },
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: true })],
  exports: [RouterModule]
})

如何导航回Component1?

0 个答案:

没有答案