注入错误,使用ui-bootstrap

Injection error, using ui-bootstrap

Unknown provider: $confirmModalProvider <- $confirmModal <- confirmModalCtrl

为什么会出现此错误?我正在尝试使用 AngularJS UI Bootstrap 打开模式并获取结果。我在触发 $scope.deleteQuestion() 时收到此错误。知道我在这里做错了什么吗?

var crtPromoCtrl = angular.module('crtPromoCtrl', ['crtPromoSrv']);

crtPromoCtrl.controller('surveyCtrl', ['$scope', '$modal', 'surveySrv', function($scope, $modal, surveySrv)
{
        $scope.questions = surveySrv.getQuestions();

    $scope.editQuestion = function(index)
    {
        surveySrv.setEditQuestion(index);
    };

    $scope.deleteQuestion = function(index)
    {
        var confirmModal = $modal.open({
            templateUrl: 'confirm-delete.html',
            controller: 'confirmModalCtrl',
            size: 'sm'
        });

        confirmModal.result.then(function(msg)
        {
            console.log(msg);
        });

        return false;
    };
}]);

crtPromoCtrl.controller('confirmModalCtrl', ['$scope', '$confirmModal', function($scope, $confirmModal)
{
    $scope.yes = function()
    {
        $confirmModal.close('yes');
    };

    $scope.no = function()
    {
        $confirmModal.dismiss('no');
    };
}]);

编辑:https://angular-ui.github.io/bootstrap/#/modal

你的第二个控制器应该使用 $modalInstance 而不是 $confirmModal

Please note that $modalInstance represents a modal window (instance) dependency.

代码

crtPromoCtrl.controller('confirmModalCtrl', ['$scope', '$modalInstance', function($scope, $modalInstance) {
    $scope.yes = function() {
        $modalInstance.close('yes');
    };

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