title: How to inject $http in ng-route templateUrl funcion?
body: <p>My web application has many views(templates) and there is no static pattern to composed the templateUrl just from route parameters.
  Considering the flexibility to update the routes, I stores the routing table in a SQL server and create a RESTful web service to retrieve&amp;update the route-template records.
  However, I find no way to call $http and $rootScope in AngularJS during configuration phrase.</p>
  
  <p>I understand .config happens before .run in AngularJS. In configuration, we can only access to constant and providers.
  But since I'm using templateUrl function, the function body is called at run time.
  I was wondering if there's any way to inject $http and $rootScope in my templateUrl function which will be executed at run phrase...</p>
  
  <pre><code>angular.module('app', ['ngRoute']).config(['$routeProvider', 
  
          function ($routeProvider) {
  
              $routeProvider.
                      when('/:param1/:param2/:param3',
                      { templateUrl: function(element){
                        // $http GET routing table from RESTful API
                        // store the table to $rootScope
                        // look up table with param1+param2+param3 as key, get template url 
                        return templateUrlFromTable ;
                      }}).
  
                      otherwise({redirectTo: '/'});
  
          }])
  </code></pre>
  
  <p>I'm very new to AngularJS, any other suggestion is also welcome.
  Also, please correct me if my understanding is wrong.
  Thanks.</p>