0

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.

1
  • Is the meaning of open side by side is open with multiple browser tabs or single page with 2 components? If with multiple browser tabs I don't think that is possible. If single page with 2 components, I suggest creating a parent component, then in the parent component what you did is render these 2 (child) components and also from parent component pass the id to child components. And your routing should change to point to the parent component. Commented Mar 19, 2022 at 0:52

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.