I have two controllers. There are functions that are identical and others that are differ.
For example:
Controller 1:
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();
};
}
]);
The second controller:
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();
};
}
]);
I have partials html to use the same click event but it depends on the controller:
<div ng-click="select()"></div>
How can I avoid from duplicated code on both controllers?