I am trying to create modal window with login form using ui-bootstrap angular module.
I created two controllers but after that i realized that two controllers to one modal window is too much so i decided two merge it into one. And then i got 3 errors which i can't solve for so long, please help me.
angular.js:14239 Error: [$injector:unpr] Unknown provider: $uibModalInstanceProvider <- $uibModalInstance <- LoginModalCtrl
angular.js:14239 Error: [$injector:unpr] Unknown provider: $uibModalInstanceProvider <- $uibModalInstance <- LoginModalCtrl <- LoginModalCtrl
Error: [$injector:unpr] Unknown provider: $uibModalInstanceProvider <- $uibModalInstance <- LoginModalCtrl <- LoginModalCtrl <- LoginModalCtrl
I am sure i spelled everything correctly any dependencies.
Code of two controllers which worked for me before putting them together
https://gist.github.com/anonymous/f0286abe139a02749d7b4e55d57b3fdd
And finally code of frankenstein i've created from mixing them.
app.controller('LoginModalCtrl', ['$scope', '$location', '$uibModalInstance', '$uibModal', 'authenticationService', function($scope, $uibModal, $uibModalInstance, $location, authenticationService) {
var $ctrl = this;
$ctrl.modalInstance = null;
$ctrl.animationsEnabled = true;
$ctrl.open = function(size, parentSelector) {
var parentElem = parentSelector ?
angular.element($document[0].querySelector('.modal-login' + parentSelector)) : undefined;
$ctrl.modalInstance = $uibModal.open({
animation: $ctrl.animationsEnabled,
ariaLabelledBy: 'modal-header',
ariaDescribedBy: 'modal-body',
templateUrl: 'loginModalContent.html',
backdropClass: "modal-backdrop",
size: size,
backdrop: true,
appendTo: parentElem,
resolve: {
items: function() {
return $ctrl.items;
}
}
});
};
$ctrl.login = function() {
//
authenticationService.login($ctrl.loginData)
.then(function(data) {
$uibModalInstance.close();
$location.url("/");
}, function(error) {
});
};
$ctrl.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
}]);
['$scope', ... , 'authenticationService']andfunction($scope, ... , authenticationService)should have the identical order. - Prerak Sola