-1

I have a routing.module.ts file that contains the following code:

export const routes: Routes = [
    ...
    { path: ‘profile/:id’, component: ProfileComponent }
];

I have an app.component.ts file that contains the template:

<div class=“app-container”>
    <header></header>
    <div class=“body”>
        <router-outlet></router-outlet>
    </div>
</div>

When I try to navigate to this site using a query param, e.g mysite.com/profile/1234?q=5, I get a 404 for mysite.com/profile/1234%3Fq%3D5

How do I make it so that the router-outlet doesn’t include the query parameter portion of the request?

Dylan
  • 949
  • 3
  • 13
  • 23

1 Answers1

0

In your router.navigate() method, try to pass the URL by first decoding it as

router.navigate([decodeURIComponent(url)]);

Activated Route does not encode the URL before accessing the parameters

Saksham
  • 9,037
  • 7
  • 45
  • 73