Reputation: 22964
In angular.js, how can I set the route using an anchor tag's href, but containing a query parameter too? I'm using html5Mode and it seems that the following:
<a href="/my/profile?scrollTo=someElementId"></a>
ends up escaping the question mark before it sets the url.
I need to set the url exactly as is. How can I prevent it from escaping the question mark?
Upvotes: 1
Views: 1852
Reputation: 6104
If you are using the default Angular router, the documentation says it all. Take a look at their example here.
If you are looking for a more robust router, I suggest you switch to ui-router.
Here's how you deal with query params, although you might just use URL parameters instead for pretty URLs.
With ui-router you don't have to use
href
, you can pass query params to a route using ui-sref. Check out this example to see how.
Upvotes: 2