title: Avoiding duplicated code in AngularJs
body: <p>I have two controllers. 
  There are functions that are identical and others that are differ.</p>
  
  <p>For example:</p>
  
  <p>Controller 1:</p>
  
  <pre><code>app.controller('ControllerOne', ['$scope','HelperService',
      function ($scope, HelperService) {
          $scope.helperService = HelperService; //get an instance of the HelperService
  
          $scope.select = function () {
              $scope.helperService.doA();
              $scope.helperService.doB();
              $scope.helperService.doC();
          };
  
          $scope.filter = function () {
              $scope.helperService.doB();
              $scope.helperService.doC();
              $scope.helperService.doE();
              $scope.helperService.doF();
          };
      }
  ]);
  </code></pre>
  
  <p>The second controller:</p>
  
  <pre><code>app.controller('ControllerOne', ['$scope','HelperService',
      function ($scope, HelperService) {
          $scope.helperService = HelperService; //get an instance of the HelperService
  
          $scope.select = function () {
              $scope.helperService.doA();
              $scope.helperService.doB();
              $scope.helperService.doC();
              $scope.helperService.doD();
          };
  
          $scope.filter = function () {
              $scope.helperService.doB();
              $scope.helperService.doC();
              $scope.helperService.doD();
              $scope.helperService.doF();
          };
      }
  ]);
  </code></pre>
  
  <p>I have partials html to use the same click event but it depends on the controller:</p>
  
  <pre><code>&lt;div ng-click="select()"&gt;&lt;/div&gt; 
  </code></pre>
  
  <p>How can I avoid from duplicated code on both controllers?</p>