Reputation: 757
I want to route to this page passing a param: http://localhost:4200/inventory/client?id=2
What I do is:
this.router.navigate(['/inventory/client',{id:this.vendorId}]);
But result involves a semicolon: http://localhost:4200/inventory/client;id=2
What should i do to change it to: http://localhost:4200/inventory/client?id=2
Upvotes: 2
Views: 15703
Reputation: 534
this.router.navigate(['/inventory/client',
queryParams :
{
id : (this.vendorId ? this.vendorId : '')
}
]);
Upvotes: 1
Reputation: 222522
You should use queryParams
this.router.navigate(['/inventory/client'], { queryParams: { id: this.vendorId} });
Upvotes: 0
Reputation: 1738
Try this:
this.router.navigate(['/inventory/client'], { queryParams: { id: this.vendorId} });
And have a look here: Passing Optional Parameters
Upvotes: 4