10

I am fairly new to Angular 2 and do not know the correct terms to search for in order to get what i need.

I am using Angular 2 RC5 and the RouterModule in my app. When I pass params for a route to navigate to, Angular 2 Router automatically URL encodes it. Now although thats a good thing but is there a way to prevent it for certain params?

For example, I want to add comma separated values in the URL: http://localhost:4200/appcomponent/?data=abc1,abc2,abc3

What angular 2 makes it: http://localhost:4200/appcomponent/;data=abc1%2Cabc2%2Cabc3 (which looks rather messy)

Any suggestions how to make it more readable in URL?

Thanks!

4
  • can you specify exact router library that you are using and provide your code? thanks! Commented Aug 20, 2016 at 7:57
  • I am using the default router library from Angular 2 (@angular/router: 3.0.0-rc.1) let paramsObject = {data: 'abc1,abc2,abc3'}; this.router.navigate(['/appcomponent', paramsObject]); Commented Aug 20, 2016 at 9:26
  • check out my answer below for similar Question: stackoverflow.com/questions/41476193/… Commented Feb 2, 2017 at 6:45
  • 1
    Possible duplicate of angular 2 disable url encoding Commented Feb 2, 2017 at 14:30

1 Answer 1

14

You could navigate by Url instead:

 router.navigateByUrl('/parent/11/(simple//right:user/victor)');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.