title: How to programmatically create URLs with AngularJS
body: <p>Currently I am toying with the AngularJS framework. I'm using the $route service for deep linking into my single-page application.</p>
  
  <p>Now I would like to navigate inside my application, say, by changing just the search part of the current URL. It is easy to do using the $location service in JavaScript, but how can I construct an href attribute from the current route with just the search part replaced?</p>
  
  <p>Do I have to do it by hand or is there an AngularJS way for it?</p>
  
  <p><em>Added:</em></p>
  
  <p>Of course, the $location service has all methods to calculate such URLs. But I cannot use it because $location does also navigate the browser window to the new URL.</p>
  
  <p>There is another complication with creating URLs by hand: One has to check whether the legacy #-method or the new History API is used. Depending on this, the URL has to include a #-sign or not.</p>