title: Angular and UI-Router, how to set a dynamic templateUrl
body: <p>How could I use a name fetched from my database as a templateUrl filename?</p>
  
  <p>I've tried this:</p>
  
  <pre><code>$stateProvider.state('/', {
    url: '/',
    views: {
      page: {
        controller: 'HomeCtrl',
        templateProvider: function($templateFactory, $rootScope) {
          console.log("$rootScope.template")
          return $templateFactory.fromUrl('/templates/' + $rootScope.template);
        }
      }
    }
  });
  </code></pre>
  
  <p>Which doesn't seem to work work if my $rootScope.template comes from a database query. Don't know why, but it doesn't work.</p>
  
  <p>If in my controller I do $rootScope.template = "whatever.html" everything works ok, but if I query the template from database nothing happens at all. console.log("$rootScope.template") in templateProvider gives me nothing (the query itself works just fine).</p>
  
  <p>Does the query simply take too long and it's therefore not ready for the router or what's happening here?</p>
  
  <p>That am I doing wrong and how can I fix it?</p>