2

I'm trying to navigate including query params:

this.router.navigate(['/forum/topic/1', { queryParams: { reply: 5 } }]);

But it redirect me to /forum/topic/1;queryParams=%5Bobject%20Object%5D

Expected behavior:

/forum/topic/1?reply=5

Looking at the document I see they edit the params because I see it's separate with ;

localhost:4200/heroes;id=15;foo=foo

What are they doing ?

1) How can I fix the redirection, I think the function is fine...

2) I don't want ;, I want classic ? and &, is it possible ?

PierreD
  • 860
  • 1
  • 14
  • 30
  • just use `this.router.navigate(['/forum/topic/1?reply=5']);`? it worked when i tried it in angular 4 i believe, so it should still work in 6 and 7, whichever youre using – mast3rd3mon Mar 05 '19 at 15:51
  • I tryed but I get forum/topic/1%3Freply%3D5 – PierreD Mar 05 '19 at 15:52
  • in which case, its encoding it for some reason – mast3rd3mon Mar 05 '19 at 15:54
  • Possible duplicate of [How to pass query parameters with a routerLink in the new Router V 3 alpha (vladivostok)](https://stackoverflow.com/questions/37880876/how-to-pass-query-parameters-with-a-routerlink-in-the-new-router-v-3-alpha-vlad) – Igor Mar 05 '19 at 16:13
  • Possible duplicate of [router.navigate with query params Angular 5](https://stackoverflow.com/q/52980345/1260204) – Igor Mar 05 '19 at 16:14

1 Answers1

3

I think you have a typo. Look at parenthesis. Try this:

this.router.navigate(['/forum/topic/1'], { queryParams: { reply: 5 } });
Rozan
  • 46
  • 2