title: AngularAMD + ui-router + dynamic controller name?
body: <p>I'm trying to write a generalized route in my application and resolve the view and controller names on the fly based on the route params.</p>
  
  <p>I have the following code that works:</p>
  
  <pre><code>$stateProvider.state('default', angularAMD.route({
      url: '/:module/:action?id',
  
      templateUrl: function (params) {
          var module = params.module;
          var action = module + params.action.charAt(0).toUpperCase() 
                              + params.action.substr(1);
  
          return 'app/views/' + module + '/' + action + 'View.html';
      },
  
      controller: 'userController',
  }));
  </code></pre>
  
  <p>However, I'm unable to figure out a way to resolve the controller name dynamically. I tried using <code>resolve</code> as described <a href="http://www.codeproject.com/Articles/808213/Developing-a-Large-Scale-Application-with-a-Single">here</a>, but ui-router seems to handle resolve differently than angular-route.</p>
  
  <p>Any pointers?</p>
  
  <p><strong>EDIT</strong>: I've already tried using <code>controllerProvider</code> but it doesn't work for me (for instance, the following code just returns a hard coded controller name to test whether it actually works):</p>
  
  <pre><code>controllerProvider: function () {
      return 'userController';
  }
  </code></pre>
  
  <p>Gives me the following error:</p>
  
  <blockquote>
    <p>Error: [ng:areq] Argument 'userController' is not a function, got undefined
    <code>http://errors.angularjs.org/1.3.3/ng/areq?p0=userController&amp;p1=not%20aNaNunction%2C%20got%20undefined</code></p>
  </blockquote>