MyAdmin.controller('AdminMasterController', ['$rootScope', '$q', '$scope', '$http', 'ApiCall', 'DTOptionsBuilder', 'DTColumnDefBuilder', '$window', 'myStorageService', '$ocLazyLoad', '$modal','$modalInstance',
function ($rootScope, $q, $scope, $http, ApiCall, DTOptionsBuilder, DTColumnDefBuilder, $window, myStorageService, $ocLazyLoad, $modal,$modalInstance)
{
$scope.btnViewClick = function (job) {
myStorageService.setMyStorage('empCode', job.EmployerCode);
$ocLazyLoad.load({
name: 'MyAdmin',
files: ['MyAdmin/angular_scripts/controllers/viewPopUpController.js'
]
}).then(function () {
$scope.modalInstance = $modal.open({
templateUrl: 'MyAdmin/angular_views/DetailsPopup/viewpopup.html',
controller: 'viewPopUpController',
size: 'sm'
});
});
}
$scope.closeModal = function () {
$modalInstance.close();
}
}]);
这里我注入modalInstance但是当页面加载时它会给我modalInstance错误
错误:[$ injector:unpr] http://errors.angularjs.org/1.3.15/ $ injector / unpr?p0 =%24modalInstanceProvider%20%3C-%20%24modalInstance%20%3C-%20AdminMasterController
答案 0 :(得分:0)
使用最新的Bootstrap UI,这两个依赖项称为$uibModal
和$uibModalInstance
。
此外,您无需将$uibModalInstance
注入控制器,因为您已在此处创建了自己的模态实例:
$scope.modalInstance = $modal.open({
templateUrl: 'MyAdmin/angular_views/DetailsPopup/viewpopup.html',
controller: 'viewPopUpController',
size: 'sm'
});
因为您现在有$scope.modalInstance
可用,所以您应该可以通过以下方式关闭它:
$scope.closeModal = function () {
$scope.modalInstance.close();
}