0

I am using angular 9 application.

I have a routing file with the below code :

{ path: 'a/:id', component: AComponent },
{ path: 'a/b', component: BComponent },
{ path: 'a/c', component: CComponent }

I want to have the same route 'a' with query parameter id as well as appended routes (b & c)

When I am trying to navigate to 'a/b' OR 'a/c', the URL in the browser gets updated, however, it doesn't actually navigates to the desired route.

Is there any way to achieve this?

Rachid O
  • 13,013
  • 15
  • 66
  • 92

1 Answers1

0

The order of routes is important because the Router uses a first-match wins strategy when matching routes, so more specific routes should be placed above less specific routes.

In your case:

{ path: 'a/b', component: BComponent },
{ path: 'a/c', component: CComponent },
{ path: 'a/:id', component: AComponent },
Rachid O
  • 13,013
  • 15
  • 66
  • 92