Home > Net >  How routing to two component? angular
How routing to two component? angular

Time:03-19

I have this routes:

const appRoutes: Routes = [
  {
    path: '',
    component: UsersComponent,
    children: [
      {
        path: 'todos/:id',
        component: TodosComponent
      },
      {
        path: 'todos/:id',
        component: PostsComponent
      }
    ]
  }

];

the TodosComponent its working, but the PostsComponent doesn't. I want that I am routing to 'todos/:id' the two components will open side by side.

CodePudding user response:

You have 2 options you can use outlet, which gives you multiple location on a component to render routed components. But since you say side-by-side. I would just do the simple thing and have a parent component. And just have each component within.

CodePudding user response:

You have to change the path. The routes are not allowed to be the same because the route that will be first matched, it will be taken, and by your example only the TodosComponent will be appeared.

  • Related