-1
angular.module('test').controller('list', function($scope) {
    // Call entire test controller here
});

angular.module('test')
    .controller('getCustomers', function($scope) {
});

I need to implement this in order to access functions in the other controller.

Mistalis
  • 17,793
  • 13
  • 73
  • 97
  • 3
    Possible duplicate of [Creating common controller functions](http://stackoverflow.com/questions/11324202/creating-common-controller-functions) – Mistalis Dec 13 '16 at 08:52

1 Answers1

0

You can extend one controller to another by using the $controller service, something like:

angular.module('test')
    .controller('list', function($scope,$controller) {
        $controller('getCustomers', {$scope: $scope});
        $scope.getCustomersFn();
});
angular.module('test')
    .controller('getCustomers', function($scope) {
        $scope.getCustomersFn = function(){}
});

This is specially usefull if you want to create controller inheritance, but consider whether using a factory/provider is best suitable for your case, because it can be a bit hard to understand if you abuse it.

olivarra1
  • 3,269
  • 3
  • 23
  • 34