How to call a multiple controllers in single template in angularjs?
angular.module('test').controller('list', function($scope) {
// Call entire test controller here
});
angular.module('test')
.controller('getCustomers', function($scope) {
});
我需要实现这个功能才能访问其他控制器中的功能。
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.
链接地址: http://www.djcxy.com/p/77570.html