title: How to use $resource to configure $stateProvider, $urlRouterProvider during config (or run?) in AngularJS
body: <p>I want to set up an Angular UI Router $urlRouterProvider $stateProvider "dynamically", based on some configuration read from a JSON resource. I've tried:</p>
  
  <pre><code>.config(function ($stateProvider, $urlRouterProvider, $resource) {
  </code></pre>
  
  <p>but that doesn't work ("Uncaught Error: Unknown provider: $resource from mui.jsAngularAddressbookApp") because (I do understand) "you can only inject Providers (not instances) into the config blocks". So then I tried:</p>
  
  <pre><code>.run(function ($stateProvider, $urlRouterProvider, $resource) {
  </code></pre>
  
  <p>but that cannot work either ("Uncaught Error: Unknown provider: $stateProviderProvider &lt;- $stateProvider") because (again I do understand the principle) "You can only inject instances (not Providers) into the run blocks". </p>
  
  <p>I've hacked / worked around it by just using jQuery.getJSON instead of $resource, but that's "not the AngularJS way" of course (does it have any real disadvantages though?).</p>
  
  <p>What's the "proper" solution to this?</p>