title: angular-ui-router: resolve on root state
body: <p>As far as I understand ui.router</p>
  
  <p>You have $stateProvider</p>
  
  <p>in it you can write $stateProvider.state()</p>
  
  <p>you can write</p>
  
  <pre><code>    .state('account', {
          url: '/account',
          template: '&lt;ui-view/&gt;'
      })
      .state('account.register', {
          url: '/register',
          templateUrl: '/account/views/register.html',
          data: { title: 'Create Account' },
          controller: 'AccountRegister'
      })
  </code></pre>
  
  <p>but 'account' is a child of some kind of root state.</p>
  
  <p>So my thought is, the root state of ui.router has a <code>&lt;ui-view/&gt;</code>, just like <code>'account'</code> has the template <code>'&lt;ui-view/&gt;'</code>, so index.html would be the root state. Even <code>'home'</code> with <code>url: '/'</code> would be or rather is a child of this root state.</p>
  
  <p>and if I'm able to access the root state and say it should resolve a User service this resolved value should be available on all states (or better on every state that is a child of the root state, aka all). The User service promise makes a <code>$http.get('/api/user/status')</code> and it returns <code>{"user":{id: "userid", role: "role"}} or {"user":null}</code>
  This would guarantee that the value returned by the User service is always populated.</p>
  
  <p>How do I access the root state and say it should resolve e.g. <code>User.get()</code>?</p>
  
  <p>Or let me rephrase that.</p>
  
  <p>A user object should be available to all controllers.
  The information about the currently logged in user is supplied by a $http.get('/api/user/status')
  That's the problem and I'm looking for a DRY solution that, assuming the api is serving, is 100% safe to assume a user object is set, aka the promise is always fulfilled, aka "waiting for the promise to resolve before continuing".</p>