title: Angular UI Router - allow ANY query string parameter
body: <p>I am using the Angular UI Router and this works well in most situations. However, I have a situation where I don't know the names of the query string parameters ahead of time.</p>
  
  <p>So normally with UI router you would define a route something like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$stateProvider.state('test', {
   url: '/test?testQueryStringParam',
   templateUrl: 'Test.html',
   controller: 'TestController'
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Then in my controller I can access the testQueryStringParam using $stateParams.</p>
  
  <p>However, with UI router you can't access any query string parameters not specified in the route definition.</p>
  
  <p>The router that comes with the Angular framework, does allow you to do this. So I have tried using the $location service with my UI router defintion. This does sort of work.</p>
  
  <p>When I want to add a query string parameter I use:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$location.search("paramName", "paramValue");</code></pre>
  </div>
  </div>
  </p>
  
  <p>When I want to get the query string values I just use:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$location.search()</code></pre>
  </div>
  </div>
  </p>
  
  <p>This updates the URL, but doesn't re-instantiate the controller (like $state.go($state.current, {}, {reload: true}) would). This doesn't seem like a big problem because I can just re-load the data myself. However, if you use the back button in the browser, again it changes the URL, but doesn't re-instantiate the controller.</p>
  
  <p>Is there anyway</p>
  
  <ol>
  <li><p>I can get this to work using just the UI Router?</p></li>
  <li><p>Get the workaround of using $location to actually re-instantiate the controller.?</p></li>
  </ol>
  
  <p>As a last resort I also tried directing updating the window.location, but this refreshes the entire page which isn't acceptable.</p>
  
  <p>Thanks</p>