title: How do I get the browser's back button to take me to my previous URL? (angular ui-router)
body: <p>I am doing my frontend routing with <a href="https://github.com/angular-ui/ui-router">angular ui router</a>, and I am seemingly unable to get my browser's back button to take me to most recent URL.</p>
  
  <p>Let me demonstrate.</p>
  
  <p>Let's say I start here</p>
  
  <pre><code>/#/myapp/
  </code></pre>
  
  <p>And after some clicks, I have dynamically adjusted my URL to become</p>
  
  <pre><code> /#/myapp/12345
  </code></pre>
  
  <p>Let's say I click a datepicker while remaining on the page</p>
  
  <pre><code>/#/myapp/12345?start=2016-01-21&amp;end=2016-01-28
  </code></pre>
  
  <p>I am able to do this by using $scope'd functions in tandem with $location.url</p>
  
  <p>Awesome. So far, so good.</p>
  
  <p>Let's say I navigate away from this by clicking</p>
  
  <pre><code>&lt;a href="#"&gt; My App &lt;/a&gt;
  </code></pre>
  
  <p>Which, due to the way I have set up my routing</p>
  
  <pre><code>myApp.config([
      '$stateProvider', '$urlRouterProvider',
      function($stateProvider, $urlRouterProvider) {
  
          $stateProvider.state('myapp',
              url : '/myapp/*id?start&amp;end',
              templateUrl : '&lt;path to my template&gt;',
              controller : '&lt;name of my controller&gt;'
          );
  
          // more routes
  
          $urlRouterProvider.otherwise('/myapp/');
  
      }
  ]);
  </code></pre>
  
  <p>will default back to the initial state </p>
  
  <pre><code>/#/myapp
  </code></pre>
  
  <p>Ok, still so far, so good. However, when I click my browser's back button, I am taken back to</p>
  
  <pre><code>/#/myapp
  </code></pre>
  
  <p>instead of what I would expect</p>
  
  <pre><code>/#/myapp/12345?start=2016-01-21&amp;end=2016-01-28
  </code></pre>
  
  <p>I can only guess that the intermediate urls that I have generated while navigating around my page were not captured by my browser's history... which I guess makes sense. How do I get my browser to recognize these intermediate steps so that I can backtrace properly?</p>