title: Angular:How to reuse service across different controller and module
body: <p>suppose i have service in angular and tell me how could i reuse that service across different controller and module. see the code</p>
  
  <p>code taken from <a href="http://viralpatel.net/blogs/angularjs-service-factory-tutorial/" rel="nofollow">http://viralpatel.net/blogs/angularjs-service-factory-tutorial/</a></p>
  
  <pre><code>&lt;div ng-app="app"&gt;
      &lt;div ng-controller="CalculatorController"&gt;
          Enter a number:
          &lt;input type="number" ng-model="number" /&gt;
          &lt;button ng-click="doSquare()"&gt;X&lt;sup&gt;2&lt;/sup&gt;&lt;/button&gt;
          &lt;button ng-click="doCube()"&gt;X&lt;sup&gt;3&lt;/sup&gt;&lt;/button&gt;
  
          &lt;div&gt;Answer: {{answer}}&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  var app = angular.module('app', []);
  
  app.service('MathService', function() {
      this.add = function(a, b) { return a + b };
  
      this.subtract = function(a, b) { return a - b };
  
      this.multiply = function(a, b) { return a * b };
  
      this.divide = function(a, b) { return a / b };
  });
  
  app.service('CalculatorService', function(MathService){
  
      this.square = function(a) { return MathService.multiply(a,a); };
      this.cube = function(a) { return MathService.multiply(a, MathService.multiply(a,a)); };
  
  });
  
  app.controller('CalculatorController', function($scope, CalculatorService) {
  
      $scope.doSquare = function() {
          $scope.answer = CalculatorService.square($scope.number);
      }
  
      $scope.doCube = function() {
          $scope.answer = CalculatorService.cube($scope.number);
      }
  });
  </code></pre>
  
  <p>the service has been declare and attached with app module. now tell me if i need to use this same service in another module call app1 then do i need to define and attach the same service there in app1 module ?</p>
  
  <p>looking for guidance.</p>