I have a web app in wich i like to insert my own custom directives, and in order to do that i have defined a new module where i define those new directives (only 1 for now) so i can reuse in the future. The problem comes when AngularJS
try to instantiate the new module, i got the following error
(i put only the first part of the log so it don't get too dificult to read):
Uncaught Error: [$injector:modulerr] Failed to instantiate module tangoInfinito due to:
Error: [$injector:modulerr] Failed to instantiate module custom.modal due to:
Error: [ng:areq] Argument 'directiveFactory' is required
http://errors.angularjs.org/1.5.9/ng/areq?p0=directiveFactory&p1=required
at http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:68:12
at assertArg (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:1937:11)
at $CompileProvider.registerDirective [as directive] (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:7845:7)
at runInvokeQueue (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:4654:35)
at http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:4662:11
at forEach (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:325:20)
at loadModules (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:4644:5)
at http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:4661:40
at forEach (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:325:20)
at loadModules (http://localhost/tangoinfinito.com.ar/js/Dependencies/angular/angular.js:4644:5)
also here is my new module:
(function() {
var app = angular.module("custom.modal", []);
// Esta directiva es para generalizar los Modals de Bootstrap 3. No debe ser usada de manera individual,
// sino como esqueleto de Modals personalizados en otras directivas.
var bootstrapModal = function() {
return {
restrict: "E",
template:
"<div class='modal fade' tabindex='-1' role='dialog' aria-labelledby='modalTitle'>" +
"<div class='modal-dialog' role='document'>" +
"<div class='modal-content'>" +
"{{ htmlModalContent }}" +
"</div>" +
"</div>" +
"</div>",
controller: "ModalController"
}
};
var ModalController = function($scope) {
$scope.htmlModalContent = "";
};
app
.controller("ModalController", ModalController)
.directive("bootstrapModal", bootstrapModal)
;
})();
I hope you can help me, i search a lot trough the web and i found almost nothing about this error. Thanks in advance.
EDIT: new error after the Phil answer:
Error: [$compile:ctreq] Controller 'bootstrapModal', required by directive 'loginModal', can't be found!
i left you my "loginModal" directive:
(function() {
var app = angular.module("tangoInfinito");
var loginModal = function() {
return {
require: "bootstrapModal",
link: function(scope, element, attr) {
scope.htmlModalContent = /* Here comes the template to be inside the modal (the modal body and footer) */
},
template: "<bootstrap-modal></bootstrap-modal>"
}
};
app.directive("loginModal", loginModal);
})();