如何在一个Controller中取到另一个Controller?下边事stackoverflow上的一个回答。

```
app.controller(‘TestCtrl2’, [‘$scope’, ‘$controller’, function ($scope, $controller) {
var testCtrl1ViewModel = $scope.$new(); //You need to supply a scope while instantiating.
//Provide the scope, you can also do $scope.$new(true) in order to create an isolated scope.
//In this case it is the child scope of this scope.
$controller(‘TestCtrl1’,{$scope : testCtrl1ViewModel });
testCtrl1ViewModel.myMethod(); //And call the method on the newScope.
}]);

1
2
3
4
> 
> In any case you cannot call TestCtrl1.myMethod() because you have attached the method on the $scope and not on the controller instance.
>
> If you are sharing the controller, then it would always be better to do:-

.controller(‘TestCtrl1’, [‘$log’, function ($log) {
this.myMethod = function () {
$log.debug(“TestCtrl1 - myMethod”);
}
}]);

1
2
3
> and while consuming do:
>
>

.controller(‘TestCtrl2’, [‘$scope’, ‘$controller’, function ($scope, $controller) {
var testCtrl1ViewModel = $controller(‘TestCtrl1’);
testCtrl1ViewModel.myMethod();
}]);
`

In the first case really the $scope is your view model, and in the second case it the controller instance itself.

参考