title: How to change templateURL for angular UI router based on customer settings
body: <p>I have multiple clients on my angular app and I want to create different themes inside angular (only the visual part will change, controllers remain the same.</p>
  
  <p>I have a "security" module which manages the authentication, currentLoggedIn user and so on.</p>
  
  <pre><code>var security = angular.module('security', ['ui.router'])
      // .factory('authService',  authService);
  .service('authService', ['$http', '$q', '$window', 'CONSTANTS', '$location', 'currentUser', '$state', '$rootScope', authService])
  .factory('authCheck', ['$rootScope', '$state', 'authService', securityAuthorization])
  </code></pre>
  
  <p>and authService is basically having these methods/values</p>
  
  <pre><code>service.login = _login;
      service.logout = _logout;
      service.reset = _reset;
      service.isAuthenticated = _isAuthenticated;
      service.requestCurrentUser = _requestCurrentUser;
      service.returnCurrentUser = _returnCurrentUser;
      service.hasRoleAccess = _hasRoleAccess;
  </code></pre>
  
  <p>How can I get access to currentUser inside templateURL function to modify the URL based on data for currentUser?
  AuthService and AuthCheck are empty when accessed in templateURL function.</p>
  
  <pre><code>$stateProvider
          .state('home', {
              url: '/home',
              templateUrl: function(authService, authCheck) {
                  console.log (authService, authCheck);
                  return 'components/home/home.html'
              },
              data: {
                  roles: ['Admin']
              },
              resolve: {
                  "authorize": ['authCheck', function(authCheck) {
                      return authCheck.authorize();
                  }],
                  "loadedData": ['metricsFactory', 'campaignFactory', '$q', '$rootScope', 'selectedDates', loadHomeController]
              },
              controller: 'HomeController',
              controllerAs: 'home'
          });
  </code></pre>