如何在同一页面中路由两个组件?

时间:2019-12-20 18:42:15

标签: angular angular2-routing angular-routing

如何在同一页面中路由两个组件?

我只能将其一侧布线。这是我的代码:

https://stackblitz.com/edit/angular-h7xt3m

1 个答案:

答案 0 :(得分:0)

您几乎拥有它!

只需用以下命令替换app-routing.module中的主要路由配置:

const routes: Routes = [
  {
    path: "",
    children: [
      { path: "", component: LeftMainPageComponent },
      { path: "", component: RightMainPageComponent, outlet: "righty" }
    ]
  } 
  /* old config for reference
  { path: "main", component: LeftBoxComponent },
  { path: "", redirectTo: "main", pathMatch: "full" }
  */
];

基于您的代码的Stackblitz:https://stackblitz.com/edit/angular-ddc9en