DAG
DAG

Reputation: 2620

Angular navigate when router parameter comes before router path

In Angular, if we have the path like this: :id/myPath instead of myPath/:id, how can I use the navigate method properly?

I need to change the parameter when I'm in current router.

I whish to do something like this:

this.router.navigate([this.router.currentUrl, 1]);

but the id 1 will be placed after the url and not before, what is correct.

How to make it to render before the url? O I need to manually work with strings?

Upvotes: 0

Views: 44

Answers (1)

Allen Wahlberg
Allen Wahlberg

Reputation: 192

Try it

this.router.navigate([1, this.router.currentUrl]);

Upvotes: 2

Related Questions