title: Failed async call in resolve
body: <p>I've added the following to my <code>app.config</code> in order to resolve a globally needed variable before allowing any of my routes to kick off their associated controller. This has been working great, however I am concerned about scenarios in which this async call falls. If that were to happen this would not resolve properly and my app would never render. How could I protect against this scenario?</p>
  
  <pre><code>var originalWhen = $routeProvider.when;
  
  $routeProvider.when = function(path, route) {
    if (!route.resolve) {
      route.resolve = {};
    }
    angular.extend(route.resolve, {
      availableCodes: function($rootScope, serverService) {
        if ($rootScope.isAuthenticated) {
          return numbersService.getAvailableCodes().$promise.then(function(data) {
            $rootScope.availableCodes = data.codes;
          });
        }
      }
    });
    return originalWhen.call($routeProvider, path, route);
  };
  </code></pre>