Search code examples
javascriptangularjsangularjs-directivelocation-href

Angular.js - create url using $location service


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..


Solution

  • 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.

    How to programmatically create URLs with AngularJS