Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Angular Router, change state params on same route #29891

radvansky-tomas opened this Issue Apr 14, 2019 · 2 comments


None yet
2 participants
Copy link

radvansky-tomas commented Apr 14, 2019

Hi everyone, I tried to follow docs and example, but I have no idea how to reload same route with different params, if you have idea what route you are in.

Described here:

But basically lets say that your convention is


And you want to change appId from some global scope. So you can this.router to access current Angular Router instance, and you want to call .navigate() method and load same route but with different appId param.

Any idea, how to do such simple thing ? I am not interested in string parsing url techniques or other "hacky" ideas, thx


This comment has been minimized.

Copy link

radvansky-tomas commented Apr 15, 2019

Hack solution looks like this:

  const url = this.router.routerState.snapshot.url.toLowerCase();
      const regex = /(?<=\/pages\/)([^/]*)/gm;

      if (url.includes('/pages/') && !url.includes('/app-management') && !url.includes('/profile')) {
        //replace appId
        console.log(url.replace(regex, "123"))

If you look at the code you will realise that from URL i cannot really access state params by its name and I have to make hard-coded exceptions etc to change state param.

I am quite sure that has to be a method which can parse current URL with params. Then change param and pass url back to router.


This comment has been minimized.

Copy link

radvansky-tomas commented Apr 15, 2019

@ngbot ngbot bot added this to the needsTriage milestone Apr 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.