Some random IT boy
Some random IT boy

Reputation: 8477

Change angular router URL scheme

When I try to pass some parameters to my URL the angular router provides some URL schemes that I don't really like.

The URLS in this example look like this:

https://whatever.io/crisis-center;id=2;foo=foo

And I would like them to look like some 'conventional' URLs.

Something like: https://whatever.io/crisis-center?id=2&foo=foo

Is there a way to change the URL scheme for the Angular2^ router? If so, any advice or example on how to do it?

Upvotes: 0

Views: 360

Answers (1)

Sarthak Aggarwal
Sarthak Aggarwal

Reputation: 2312

You can use query parameters when routing in angular

this.router.navigate(['/crisis-center'], { queryParams: { id: 2, 'foo': 'foo' } });

Your URL will look like this :

http://localhost:4200/crisis-center'?id=2&foo=foo

Upvotes: 2

Related Questions