I have a module 'paramApp' with controller 'ParamCtrl':
var app = angular.app('paramApp', []);
app.controller('ParamCtrl', ['$scope', '$http', function($scope, $http) {
.
.
.
}]);
I have another module 'deviceApp' with directive 'DeviceDirective':
var app2 = angular.app('deviceApp', []);
app2.directive('DeviceDirective', function() {
return {
.
.
.
controller: // I want to reference ParamCtrl here
controllerAs: param
};
});
I read somewhere that I need to use angular.injector (or $injector) to inject the controller, but I'm not so sure how to use it. My attempts to use the injector didn't work.
Is this approach right? Do I need to declare 'paramApp' in 'deviceApp' declaration like this,
var app2 = angular.app('deviceApp', ['paramApp']);
Please help on how to use injector in the directive controller to reference another module's controller.