I have an application with add and edit modal,when click edit or add ;it's open a modal. my Problem is :I want to have a function that's open a modal Just by call it and this function I want to define it in the root scope,when I do that I have an error in the resolve function.
DefaultModule.controller("navCtrl", function ($scope, $rootScope, $uibModal) {
$rootScope.OpenModal = function (templateModalUrl, controllerModal, resolveFun) {
$uibModal.open({
animation: true,
templateUrl: templateModalUrl,
controller: controllerModal,
resolve: {
resolveFun
}
}).result.catch(function (res) {
if (!(res === 'cancel' || res === 'escape key press')) {
//throw res;
}
});
}
});
calling it:
$scope.editBusiness = function (business) {
var ObjResolve = function () {
return business;
}
$rootScope.OpenModal("BusinessTypesModal.html", "ModalInstanceCtrl", ObjResolve);
};
and the error that's I get:
Error: $injector:unpr Unknown Provider Unknown provider: ObjResolveProvider <- ObjResolve <- ModalInstanceCtrl
P.S. the template of the modal is defined in another controller -not navCtrl Controller-