title: AngularJS [UI-Router] urlRouteProvider.when() versus resolve for routing to child states
body: <p>In my app I have a state called 'dashboard' with multiple child states</p>
  
  <pre><code>.state('dashboard', {
      url: '/dashboard',
      abstract: true,
      // resolve async objects before controller instantiation.
      resolve: {
          productResolve: function ($state, authService, cacheService, productService) {
              var cache = cacheService.getCache();
              if (cache.length === 0){
                  return productService.getProductsAndCommoditiesAsync(authService.getCredentials().roleID)
                      .then(function(productData){
                          cacheService.setCache(productData);
                      },
                      function(errorMessage){
                          $state.go('error',{errorMessage:errorMessage});
                      });                         
              }               
         }
      },        
      templateUrl: '/static/app/partials/dashboard.html',
      controller: 'dashboardCtrl',
  })
  // parent state: dashboard
  .state('dashboard.splash', {
      templateUrl: '/static/app/partials/dashboard.splash.html',
      controller: 'dashboard.splashCtrl'
  })
  // parent state: dashboard
  .state('dashboard.podSelector', {    
      // params array can be used instead of url to populate $stateParams
      params: ['productIndex', 'commodityIndex'],
      templateUrl: '/static/app/partials/dashboard.pod-selector.html',           
      controller: 'dashboard.podSelectorCtrl'
  </code></pre>
  
  <p>Which child state the user will be redirected to depends on his/her session cookie, and I was curious where the appropriate place was to do the redirecting. </p>
  
  <p>One option I can think of are either to set the parent dashboard state to be not abstract so it is able to be navigated to, then check the session from within the dashboard parent resolve promise, and do a $state.go to a child depending on the result. I ideally would like to keep the dashboard parent state abstract as its useless on its own, but if it always will redirect to a child state then I guess its not important if it is.</p>
  
  <p>The alternative I was thinking of is to handle it with a $urlRouterProvider.when(), something like:</p>
  
  <pre><code>$urlRouterProvider.when('/dashboard', function($state, sessionService){
      if (sessionService.getSession() === undefined) {
          $state.go('dashboard.splash');
      }
  }); 
  </code></pre>
  
  <p>This seems cleaner and a more logical place to put it, but say if I'm transitioning to the dashboard state from a login state, if I redirect in the resolve I can transition from the login page with a $state.go('dashboard') while if I use $urlRouterProvider I need to do a $location.path('/dashboard'), which I don't know how much transitioning to states with location paths versus $state.go is frowned upon.</p>
  
  <p>Any advice would be appreciated. </p>