title: angularjs $routeProvider route is executed before resolve completes
body: <p>I would like the route.resolve method(s) to fire before the actual route code is run.  Unfortunately in the code below,  prime() gets called but it is called asynchronously and the route code gets called before the prime completes.  I thought the resolve methods of a route was suppose to complete before the route is loaded? </p>
  
  <p></p>
  
  <pre><code>(function () {
  'use strict';
  
  var app = angular.module('app');
  
  // Collect the routes
  app.constant('routes', getRoutes());
  
  // Configure the routes and route resolvers
  app.config(['$routeProvider', 'routes', routeConfigurator]);
  function routeConfigurator($routeProvider, routes) {
  
      routes.forEach(function (r) {
          setRoute(r.url, r.config)
  
      });
  
      $routeProvider.otherwise({ redirectTo: '/' });
  
      function setRoute(url, definition) {
          //set resolvers for all of the routes
          //by extending any existing resolvers (or creating a new one)
          definition.resolve = angular.extend(definition.resolve || {}, {
               prime: prime
          });
  
  
          $routeProvider.when(url, definition);
          return $routeProvider;
      }
  
  
  }
  
  prime.$inject = ['datacontext'];
  
  function prime(dc) {
      dc.prime();
  }
  
  
  // Define the routes 
  function getRoutes() {
      return [
          {
              url: '/',
              config: {
                  templateUrl: 'app/dashboard/dashboard.html',
                  title: 'dashboard',
                  settings: {
                      nav: 1,
                      content: '&lt;i class="icon-dashboard"&gt;&lt;/i&gt; Dashboard'
                  }
              }
          },
          {
              url: '/sessions',
              config: {
                  title: 'admin',
                  templateUrl: 'app/sessions/sessions.html',
                  settings: {
                      nav: 2,
                      content: '&lt;i class="icon-calendar"&gt;&lt;/i&gt; Sessions'
                  }
              }
          },
          {
              url: '/speakers',
              config: {
                  title: 'speakers',
                  templateUrl: 'app/speakers/speakers.html',
                  settings: {
                      nav: 3,
                      content: '&lt;i class="icon-user"&gt;&lt;/i&gt; Speakers'
                  }
              }
          },
          {
              url: '/attendees',
              config: {
                  title: 'attendees',
                  templateUrl: 'app/attendees/attendees.html',
                  settings: {
                      nav: 4,
                      content: '&lt;i class="icon-group"&gt;&lt;/i&gt; Attendees'
                  }
              }
          }
      ];
  }
  })();
  </code></pre>