title: Get previous location in Angularjs ui-router
body: <p>I know we can use <code>fromState</code> and <code>fromParams</code> in the <code>$stateChangeSuccess</code> to get all information about previous location. Like said here:</p>
  <p><a href="https://stackoverflow.com/questions/16635381/angularjs-ui-route-get-previous-state">Angular - ui-router get previous state</a></p>
  <pre><code>$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {
     
  });
  </code></pre>
  <p>But is there <strong>nice</strong> way to parse it into the <strong>url / location</strong> though? For example:</p>
  <blockquote>
  <p>State: /page/:id/paragraph/:line</p>
  <p>Params: id and line, etc..</p>
  </blockquote>
  <p>What I want:</p>
  <blockquote>
  <p>/page/3/paragraph/5 ...</p>
  </blockquote>
  <p>I mean this could get messy with bunch of <em>params</em>. Plus <code>Angularjs ui-router</code> could also have <code>{{ id }}</code> as params too instead of <code>:id</code>. Isn't there a function to do this already or I have to use RegEx? And if so, what is the RegEx string to use?</p>
  <p>Thanks.</p>