title: Can you pass an Angular service as a parameter to a function provided by another Angular service?
body: <p>I have a bunch of functions throughout my Angular app using mostly the same code. So I decided to create a service which is made of the frequently duplicated code, and takes as parameters the differences.</p>
  
  <p>One of the primary and few differences each of the duplicate functions have is that they use different services.</p>
  
  <p>So for example, in a simplified excerpt, one has:</p>
  
  <pre><code>$scope.signin = function(email, password){
          loginSrvc(email, password).execute()
              .success(function(data, status, headers, config){
                  if (status == 200){
                  .... 
  </code></pre>
  
  <p>and one has </p>
  
  <pre><code>  $scope.logout = function(){
          $scope.loading = true;
          signoutSrvc().execute()
              .success(function(data, status, headers, config){
                  if (status == 200){
                  ....
  </code></pre>
  
  <p>but essentially they are the same thing.</p>
  
  <p>I want to be able to pass the services each function is using, for example <code>loginSrvc</code>, <code>signoutSrvc</code>, etc to an external service which handles all of this sort of code.</p>
  
  <p><strong>However</strong>, when I pass the service to my new service, it appears on the other end as <code>undefined</code>.</p>
  
  <p>My new service looks like:</p>
  
  <pre><code>sharedFunctionsApp.factory('serverCommunicationFactory', [function(){
      console.log("serverCommunicationFactory");
      return function(service){
          console.log(service);
          service.execute();
      }
  }]);
  </code></pre>
  
  <p>and I pass services to it from other modules (after injecting the <code>ShareFunctions</code> module of course) like this:</p>
  
  <pre><code>serverCommunicationFactory()(loginSrvc);
  </code></pre>
  
  <p>Yet it still shows as <code>undefined</code>.</p>
  
  <p>How can I pass my services to this new shared service?</p>