Let's suppose I've got 3 urls:
/:projectId/info
,
/:projectId/users
,
/:projectId/users/:userId/profile
. All of them have param projectId
. UI has a component to switch from one project to another. So I need:
- Get current URL
- Change param by name (e.g. projectId)
- Navigate to new url
So I need something like this.router.replaceParam(currentUrl, {projectId: 'project_id_2'})
which will transform /project_id_1/users/user_id_1/profile
into /project_id_2/users/user_id_1/profile
(and any other URL with :projectId
param)
I thought it's a simple and common problem but didn't find a solution in 1 hour. Suggested here solution doesn't work as noted in the last comment
question from:https://stackoverflow.com/questions/50784299/angular-router-how-to-replace-param