I have a controller registered like this:
myModule.controller(\'MyController\', function ($scope, ...some dependencies...)
{
....
Using
The answer you've already accepted works, and in almost all cases should be chosen...
For sake of completeness: Here is how you can use a controller from another module
(PS: Don't do this. lol :P)
var app = angular.module('myApp', ['myDirectives']);
app.controller('AppCtrl1', function($scope) {
$scope.foo = 'bar';
});
var directives = angular.module('myDirectives', []);
directives.directive('test', function($controller) {
return {
template: '{{foo}}
',
link: function(scope, elem, attrs) {
var controller = $controller('AppCtrl1', { $scope: scope });
console.log($scope.foo); //bar
}
};
});