im trying to implement the AngularJs directives to my project but i'm getting stuck with this issue. I have the App.js, ControllerA (which includes a directive on it) and ControllerB. Note that both controllers are in diferent folders: FolderA for ControllerA and FolderB for ControllerB
I want to call the directive created in ControllerA inside a html file into the FolderB.
The problem is that when I try to load the app, Angular is complaining about the module injector:
Uncaught Error: [$injector:modulerr] Failed to instantiate module private_home due to:(…)
App.js
'use strict';
angular.module("private_home", ['private.controllers'])
.config(['$stateProvider', '$translateProvider', '$urlRouterProvider',
function($stateProvider, $translateProvider, $urlRouterProvider){
...
}]);
ControllerA
'use strict';
angular.module("private.controllers", [])
.controller('ControllerA' ,['$scope', function($scope){
$scope.users= [...];
.directive('ControllerADirective' ,['controllerADirective', function(){
return{
restrict : 'E',
templateUrl : 'find.htm',
controller : 'ControllerA',
controllerAs : 'CotrollerADirective',
bindToController: true
}
}]);
ControllerB (I know it's not neccessary, but just in case...)
'use strict';
angular.module("private.controllers")
.controller('ControllerB' ,['$scope', function($scope){
}]);
And I call the directive in the html with this tag:
< controller-a-directive >< /controller-a-directive >
Thanks in advance!!
.directive('ControllerADirective' ,['controllerADirective', function(){: there is nothign to inject in that function, and there is no service named 'controllerADirective', so it should just be.directive('ControllerADirective', function() {. Please, when you ask about an error, post the exact and complete error message. Reading the message allows knowing what the error is. That's why errors have messages. - JB Nizet.directive('controllerADirective' ...- Artem K.