SaiBand
SaiBand

Reputation: 5355

Angular 2 Routing adding query paramaters

I am using Angular 2. I have an URL:

http://localhost:3000/#/briefcases/35/proposals

This URL is fine. But now I want to pass additional info with this URL. I want to add SortOrder and SortBy.

How do I accomplish this? What I want is something like this:

http://localhost:3000/#/briefcases/35/proposals?SortBy=Property&SortBy=Desc

How can I do this using Router.Navigate?

Upvotes: 0

Views: 63

Answers (1)

DeborahK
DeborahK

Reputation: 60518

You navigate to a route with query parameters using syntax something like this:

this.router.navigate(['/proposals'], 
   { 
    queryParams: { sortBy: 'property', sortOrder: 'Desc' }
   }
);

I have a more complete example here: https://github.com/DeborahK/Angular-Routing

Upvotes: 1

Related Questions