Wednesday 1 September 2021

How to reuse route on query params change, but not on path params change in Angular?

Say I have 2 routes '/users' and /users/:id. First one renders UserListComponent and second UserViewComponent.

I want to re-render component when navigating from /users/1 to /users/2. And of course if I navigate from /users to /users/1 and vice versa.

But I DON'T want to re-render component if I navigate from /users/1?tab=contacts to /users/1?tab=accounts.

Is there a way to configure router like this for entire application?

--

Update:

I'm importing RouterModule in AppRoutingModule like this:

RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })

I'm using Angular 12



from How to reuse route on query params change, but not on path params change in Angular?

No comments:

Post a Comment