Reputation: 3009
In Angular 2, how do I include a question marks and an equal sign in a URL? I've tried the following two ways:
In the html:
routerLink="./Example?tour=true"
and in TypeScript:
this.router.navigate(['/Example?tour=true']);
Both examples result in: /Example%3Ftour%3Dtrue
How do I get my URLs to work and display the way I want?
Upvotes: 3
Views: 1290
Reputation: 2327
I believe this is what you're looking for: adding the queryParams object.
this.router.navigate(['/Example'], {queryParams:{tour:true}});
edit: documented here: https://angular.io/docs/ts/latest/api/router/index/NavigationExtras-interface.html#!#queryParams-anchor
Upvotes: 5