title: Is it a good idea to communicate between services?
body: <p>I was thinking of using one service to store variables and call another service which stores the functions that call the web API that would be called by service1 - would this be a bad idea?</p>
  
  <p>For example, I have a controller that only gets the values from Service1:</p>
  
  <pre><code>(function() {
  'use strict';
  
  angular
      .module('app.event')
      .controller('Controller1', Controller1);
  Controller1.$inject = ['service1', '$stateParams'];
  
  /**
   * Controller 1
   * @constructor
   */
  function Controller1(service1, $stateParams) {
      // Declare self and variables
      var vm = this;
      vm.number = 0;
  
      init();
  
      /**
       * Initializes the controller
       */
      function init() {
          service1.refreshCount($stateParams.id);
          vm.number = service1.getCount();
      }
  }
  })();
  </code></pre>
  
  <p>Below is Service 1, which only stores variables and a reference to a function which is in Service2:</p>
  
  <pre><code>(function() {
      'use strict';
  
      angular
          .module('app.event')
          .factory('service1', service1);
  
      service1.$inject = ['service2'];
  
      /**
       * The event index service
       * @constructor
       */
      function service1(service2) {
          // Declare
          var count = 0;
  
          // Create the service object with functions in it
          var service = {
              getCount: getCount,
              setCount: setCount,
              refreshCount: refreshCount
          };
  
          return service;
  
          ///////////////
          // Functions //
          ///////////////
  
          /**
           * Refreshes the count value
           */
          function refreshCount(id) {
              service2.getCounts(id).then(
                  function (response) {
                      setCount(response.data.Count);
              });
          }
  
          /**
           * Returns the count value
           */
          function getCount() {
              return count;
          }
  
          /**
           * Updates the count
           * @param {int} newCount - The new count value
           */
          function setCount(newCount) {
              count = newCount;
          }
      }
  })();
  </code></pre>
  
  <p>And below would be a part of Service2, where the function is called from Service1:</p>
  
  <pre><code>// Gets a count from the DB
  getCounts: function(id) {
      $http({ url: APP_URLS.api + 'WebApiMethodName/' + id, method: 'GET' }).then(function (response) {
          return response.data.Count;
      });
  },
  etc : function() {},
  etc : function() {}
  </code></pre>
  
  <p>Is this a good idea, or is there something bad about communicating between services in this way?</p>