title: AngularJS, ui.router, load template and controller based on user role
body: <p>I have developed a Single Page App that uses a REST api. Users are required to login to access the application. When a user logs in they are redirected to /dashboard. On this URL / route, I would like to load a different template and controller based on the role of the user (e.g. normal <strong>user</strong> or <strong>admin</strong> user).</p>
  
  <p>I have looked at <a href="https://github.com/angular-ui/ui-router/wiki">https://github.com/angular-ui/ui-router/wiki</a> under the templates section but none of the options support what I am trying to achieve.</p>
  
  <ul>
  <li>By using templateUrl and function (stateParams) I am not able to <em>inject</em> the service that helps me to determine the user role so that I can load the template, e.g. views/<strong>user</strong>/dashboard.html or views/<strong>admin</strong>/dashboard.html</li>
  <li>By using templateProvider I am to inject the service that helps me to determine the user role, but how do I then load the template?</li>
  </ul>
  
  <p>Any solution should also load different controllers based on the user role, for example UserDashboardController or AdminDashboardController.</p>
  
  <p><em>So essentialy what I need is a single route that loads a different template AND controller based on a user role variable that is set in a service when a user logs in.</em></p>
  
  <p>Am I thinking along the right lines, or should I be implementing another solution?</p>
  
  <p>Any help on this would be greatly appreciated.</p>