title: Delay Injecting angular service until function is run
body: <p>I am running into a dependency catch 22.  Service A must run before service B to install some method hooks that service B will use.  However, I want one of the installed methods to use service B.  Service A and B will both initialize before any other code is run, my init logic is responsible for that.</p>
  
  <p>The easiest thing for me to do would be to make service A install a method that uses service B, but does not actually load service B until the method installed by service A is run.  Thus A can run before B, installing all the hooks required, but can still use service B when the appropriate methods is called, at which time it's safe for B to initialize since A has already done it's thing.</p>
  
  <p>Is there a convenient way to do this in Angular?  It looks like the $inject service might do this, but if so I'm not certain how to make it work.</p>
  
  <p>edit: I didn't add psudo code originally because the example I have uses restangular and would get confusing.  I've tried to come up with some stupid psudo-code example of something similar, though my actual situation is not quite as straight forward, I don't get circle dependencies, just odd behavior if the dependencies are not right.</p>
  
  <pre><code>angular.model('myProj.common').factory('RestCaller', funciton(){
  
      var route:
  
      return{ route: function(route) {
          var get: function() { //does stuff };
          var save: function() //does stuff
          var getPermissions function(PermissionService) {
              PermissionService.getPermissions(route);
          }
      };
    });
  
    angular.model('myProj.common').factory('PermissionService', funciton(RestCaller){
  
      return{
                getPermissions: function(route)  {
                       return RestCaller.route(route).get();
                }
             }
     )};
  </code></pre>
  
  <p>Here restCaller uses PermissionService for one method; but PermissionService uses RestCaller.  If I can inject PermissionService into the getPermission method I'm fine and this works.  If I have to inject PermissionService into the Factory it doesn't work; since both are dependent on each other.</p>