Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular2 router avoid url encoding

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!

like image 803
Hassan Avatar asked Aug 20 '16 07:08

Hassan


1 Answers

You could navigate by Url instead:

 router.navigateByUrl('/parent/11/(simple//right:user/victor)');
like image 187
null canvas Avatar answered Oct 23 '22 22:10

null canvas