title: angular ui-router: get $state info of toState in resolve
body: <p><strong>Update</strong>: this should be possible in angular-ui-router as of <code>1.0.0alpha0</code>. See the release notes <a href="https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0">https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0</a> and the issue <a href="https://github.com/angular-ui/ui-router/issues/1018">https://github.com/angular-ui/ui-router/issues/1018</a> I created.</p>
  
  <p>I would like to access the state's name and other attributes the app is navigating to using angular ui-router when working on the resolve. </p>
  
  <p>The reason: I want load some user data (including their access rights) asynchronously before allowing the app the enter that page. </p>
  
  <p>Currently this is not possible because injecting $state into the resolve points to the state you're navigating away form, not to the one you're navigating to.</p>
  
  <p>I know I can:</p>
  
  <ul>
  <li>get the toState somewhere else with $rootScope('$stateChangeStart') and save it in my settings service for instance. But I think it's a little messy.</li>
  <li>hard code the state into the resolve, but I don't want to reuse my resolve for all pages</li>
  </ul>
  
  <p>I also created an issue on the ui-router github (Please + 1 if you are interested!):
  <a href="https://github.com/angular-ui/ui-router/issues/1018">https://github.com/angular-ui/ui-router/issues/1018</a></p>
  
  <p>Here's my code so far. Any help appreciated!</p>
  
  <pre><code>.config(function($stateProvider) {
  
      $stateProvider.state('somePage', {
          // ..
          resolve: {
              userData: function($stateParams, $state, Settings) {
                  return Settings.getUserData() // load user data asynchronously
                      .then(function (userData) {
                          console.log($stateParams);
                          console.log($state);
                          // Problem: $state still points to the state you're navigating away from
                      });
              }
          }
      });
  });
  </code></pre>