For completeness thought I'd share this SO question. The question and answers are old but there's a good chance the answer still applies.
Angular.js - create url using $location service
-
26-06-2022 - |
Question
Is there a way to do it?
If the current url is say..
/table?sort=activity
and I wanted to update it right away, I'd do
$location.url(null, {sort: 'something'})
but what if I wanted to get back the updated url /table?sort=something
without updating it?
All the $location
functions seems to change the url right away when used with parameters..
La solution
Autres conseils
What you are looking for is $location.search()
It would look something like this:
$location.search({sort: 'something'});
Update based on comments
According to the Developers Guide, you can use the following to read the URL:
$location.absUrl();
To read the hash:
$location.path();
To read the query params:
$location.search();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow