AngularJs ui.bootstrap - 模态显示错误 [$injector:unpr]

AngularJs ui.bootstrap - Modal show error [$injector:unpr]

我正在尝试使用 angular ui.bootstrap 来实现一些功能,例如 this 但这显示了一个错误

[$injector:unpr] http://errors.angularjs.org/1.5.2/$injector/unpr?p0=%24modalProvider%20%3C-%20%24modal%20%3C-%20ngReallyClickDirective

我的密码是

app.js

var app = angular.module('app',['ui.router','oc.lazyLoad','ui.bootstrap','ngReallyClickModule']);

ngReallyClickModule.js

angular.module('ngReallyClickModule',['ui.router'])
    .directive('ngReallyClick', ['$modal',
        function($modal) {

            var ModalInstanceCtrl = function($scope, $modalInstance) {
                $scope.ok = function() {
                    $modalInstance.close();
                };

                $scope.cancel = function() {
                    $modalInstance.dismiss('cancel');
                };
            };

            return {
                restrict: 'A',
                scope:{
                    ngReallyClick:"&",
                    item:"="
                },
                link: function(scope, element, attrs) {
                    element.bind('click', function() {
                        var message = attrs.ngReallyMessage || "Are you sure ?";


                        var modalHtml = '<div class="modal-body">' + message + '</div>';
                        modalHtml += '<div class="modal-footer"><button class="btn btn-primary" ng-click="ok()">OK</button><button class="btn btn-warning" ng-click="cancel()">Cancel</button></div>';

                        var modalInstance = $modal.open({
                            template: modalHtml,
                            controller: ModalInstanceCtrl
                        });

                        modalInstance.result.then(function() {
                            scope.ngReallyClick({item:scope.item}); 
                        }, function() {
                            //Modal dismissed
                        });


                    });

                }
            }
        }
    ]);

查看

<a ng-really-message="Are you sure ?" ng-really-click="test(item)" item="item" ng-repeat="item in [1,2,3,4,5]">Delete</a>

我希望在 ng-really-click 单击时出现模式对话框。并在单击模态确定按钮时调用当前控制器的函数。

我正在使用 angular-ui-routeroclazyLoading

答案来自错误,您正在使用一些您没有使用的提供商 defined/injected。

考虑到您在此处进行了多次注入,因此很难确切地说出问题所在,但从您给我们的错误来看,没有 $modal 的提供程序。 AngularUI 最近切换到 uib 作为其大多数提供程序和指令的前缀(即 $uibModal)。尝试使用新版本。

https://angular-ui.github.io/bootstrap