mn_dev
mn_dev

Reputation: 82

How routing to two component? angular

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.

Upvotes: 0

Views: 758

Answers (2)

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.

Upvotes: 1

Refat Alsakka
Refat Alsakka

Reputation: 561

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.

Upvotes: 0

Related Questions