title: $http request in angular config - Is it possible?
body: <p>I am trying to make an $http call inside my publicApp.config in order to retrieve an array of available routes to match with the $urlMatcherFactoryProvider.</p>
  
  <p>Right now, I am hard-coding them to be <code>pageUrls = ['about','contact','another-page'];</code></p>
  
  <p>But I have an url in my express API which returns an array of available URLS. The api URL is <code>"/page-urls"</code></p>
  
  <p>Would it be possible to make an <code>$http.get('/page-urls')</code> request inside the config? I know $http is available inside <code>run()</code>, but I need the list of available URLs BEFORE routing via the $stateProvider.</p>
  
  <pre><code>(function() {
      'use strict'
  
      var pageUrls = [];
  
      var publicApp = angular.module('publicApp', ['ui.router'])
  
      publicApp.config(['$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider', function($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider) {
  
          pageUrls = ['about','contact','another-page'];  
  
          var urls = pageUrls.join('|');
          var urlMatcher = $urlMatcherFactoryProvider.compile("/{source:(?:" + urls + ")}");
  
  
          $stateProvider      
              .state('/', {
                  url: '/',
                  templateUrl: "views/home/home.view.html",
                  controller: "homeCtrl"
              })
              .state('urls', {
                      url: urlMatcher,
                      templateUrl: "views/pages/page.view.html",
                      controller: "pageCtrl"
                  });
  
              $urlRouterProvider.otherwise('/');
  
  
      }]);
  
  
  
  })();
  </code></pre>