I am attempting to build a custom modal service to accept data and produce a modal with those inputs; however, I am receiving the unknown provider error is Angular when passing the literal identifier of the controller to the controller
property of the modal.
I've got dependency injection working elsewhere in my application; it is only failing, here. There are a number of questions on SO dealing with this issue, I know; however, out of those that I have read, I am unable to find a more generic answer that might begin to point me in the right direction.
Here is my service code:
angular.module('app').service('CustomModalService', ['$uibModal', function ($uibModal) {
this.openCustomModal = function (size, title, message, action) {
var actionToPerformOnConfirm = action;
var modalInstance = $uibModal.open({
templateUrl: 'templates/CustomModal.html',
controller: 'CustomModalInstanceController',
controllerAs: 'vm',
size: size,
resolve: {
content: function () {
return {
title: title,
message: message
};
}
}
});
modalInstance.result.then(function (actionToPerformOnConfirm) {
console.log('something happened');
}.bind(this));
};
}]);
And here is the modal Controller, referenced, above:
angular.module('app').controller('CustomModalInstanceController', function ($uibModalInstance, content) {
var vm = this;
vm.title = content.title;
vm.message = content.message;
$scope.confirmAction = function () {
$uibModalInstance.close();
};
$scope.cancelAction = function () {
$uibModalInstance.dismiss('cancel');
};
});
This should be enough from what I understand of Angular. Everything works in this service, otherwise, if the controller reference is removed.
There's even this question (a great summation of all the questions I have encountered) which corroborates the documentation and the numerous examples I have seen online; yet, I am still getting the unknown provider error. This user even asks the same question (again, from what I can see, my code is a shining example of "correct")!
To show that both are in the same directory, here is a picture of the directory structure:
Where do I need to begin to look to resolve this issue? Is this an application configuration issue?