$ uibModalProvider< - $ uibModal< - StatusModalService给出错误

时间:2016-07-01 16:00:11

标签: javascript angularjs angularjs-directive angular-ui-bootstrap

尝试用angularjs和ui-bootstrap构建一个模态:

版本

  • Angularjs及其成分是1.5.3

  • UI-自举-TPLS-1.3.3.js。

在主应用文件中,我已将' ui.bootstrap' 列为

var App = angular.module('aotaApp', ['ui.router','ui.bootstrap','checklist-model','ngSanitize'])
.controller("myController", function($scope,$state, $http)

在StatusService中我将其用作

App.service("StatusModalService", ["$uibModal",
                          function ($uibModal) {
     var modalDefaults = {
         backdrop: true,
         keyboard: true,
         modalFade: true,
         templateUrl: 'resources/template/modal/confirmationModal.html'
     };
    var modalOptions = {
         closeButtonText: 'Close',
         actionButtonText: 'OK',
         headerText: 'Proceed?',
         bodyText: 'Perform this action?'
     };

     this.showModal = function (customModalDefaults, customModalOptions) {
         if (!customModalDefaults) customModalDefaults = {};
         customModalDefaults.backdrop = 'static';
         return this.show(customModalDefaults, customModalOptions);
     };

     this.show = function (customModalDefaults, customModalOptions) {
         //Create temp objects to work with since we're in a singleton service
         var tempModalDefaults = {};
         var tempModalOptions = {};

         //Map angular-ui modal custom defaults to modal defaults defined in service
         angular.extend(tempModalDefaults, modalDefaults, customModalDefaults);

         //Map modal.html $scope custom properties to defaults defined in service
         angular.extend(tempModalOptions, modalOptions, customModalOptions);

         if (!tempModalDefaults.controller) {
             tempModalDefaults.controller = function ($scope, $uibModalInstance) {
                 $scope.modalOptions = tempModalOptions;
                 $scope.modalOptions.ok = function (result) {
                     $uibModalInstance.close(result);
                 };
                 $scope.modalOptions.close = function (result) {
                     $uibModalInstance.dismiss('cancel');
                 };
             }
         }

         return $uibModal.open(tempModalDefaults).result;
     };
 }]);

但我收到错误

  

angular-1.5.3.js:13424错误:[$ injector:unpr]未知提供者:   $ uibModalProvider< - $ uibModal< - StatusModalService

我是角色的新手,主要是在app中添加ui.bootstrap。但它没有给予任何帮助。

请指导我。

3 个答案:

答案 0 :(得分:0)

这似乎是一个版本问题,需要升级你的ui-bootstrap

https://github.com/compact/angular-bootstrap-lightbox/issues/42

答案 1 :(得分:0)

安装最新版本的angular-bootstrap

npm install angular-bootstrap or bower install angular-bootstrap

答案 2 :(得分:0)

这也可能是由于重命名了$uibModal。如果遇到此错误,请尝试使用$modal