title: AngularJS set routes in App.config function conditionally
body: <p>I have a following ambiguity with AngularJS config function. 
  It seems that config function is synchronous. I want to request 
  one backend service and construct routing according to its response. 
  When I remove request and $q everything working properly. </p>
  
  <pre><code>someApp.config(['$routeProvider', '$httpProvider', '$compileProvider', 'settings',
      function ($routeProvider, $httpProvider, $compileProvider, settings) {
  
          var $http = angular.injector(['ng']).get('$http');
          var $q = angular.injector(['ng']).get('$q');
          var isUserLogged = $q.defer();
  
          $http.get(settings.apiUri + settings.loginStatus).success(function (data) {
              if (data.status == "NOT_LOGGED") {
                  isUserLogged.reject();
              } else {
                  isUserLogged.resolve();
              }
          });
  
          isUserLogged.promise.catch(function () {
               $routeProvider.
                   when('/home', {
                       templateUrl: 'partials/home.html',
                       controller: 'HomeController'
                   }).
                   otherwise({
                   redirectTo: '/home'
               });
          });
  
          isUserLogged.promise.then(function () {
              $routeProvider.
                  when('/accountsettings', {
                      templateUrl: 'partials/accountsettings.html',
                      controller: 'AccountSettingsController'
                  }).
                  otherwise({
                      redirectTo: '/accountsettings'
                  });
          });
      }]);
  </code></pre>