【问题标题】:Unknown provider: 3Provider <- 3 using Angular Bootstrap uibModal未知提供者:3Provider <- 3 使用 Angular Bootstrap uibModal
【发布时间】:2015-11-27 21:39:01
【问题描述】:

这个问题已经有几个星期了,我是 Angular 的新手,所以我希望是一个简单的解决方案。

我正在使用 Angular Bootstrap Modal (ui.bootstrap.modal),但它不工作。这是我的代码。

在 contentApp.js 上(带有额外的配置选项)

angular
    .module('contentApp', [
        'ui.bootstrap',
        'ui.router',
        'satellizer',
        'angular-jwt',
        'angular.morris-chart'
    ])

// Additional Configuration...

在 TransModalController.js 上

angular
    .module('contentApp')
    .controller('TransModalController', TransModalController)
    .controller('MICnewGroup', MICnewGroup)
    .controller('MICaddTransmitter', MICaddTransmitter);

function TransModalController($scope, $http, $uibModal, $log) {

    $scope.openModal = function (url) {

        var ModalInstanceController = "";

        if ('newGroup' == url) {
            url = "php/modal/newGroup.html";
            ModalInstanceController = 'MICnewGroup'

        } else if ('addTransmitter' == url) {
            url = "php/modal/addTransmitter.html";
            ModalInstanceController = 'MICaddTransmitter'
        };

        var modalInstance = $uibModal.open({             //<-- Line 26
            animation: true,
            templateUrl: url,
            controller: ModalInstanceController,
            size: 'sm',
            resolve: {
                user: $scope.sub
            }
        });
    };
}


// Controller for Modal Instance of New Group
function MICnewGroup($scope, $http, $state, $uibModalInstance, user) {
    $scope.newGroup = {
        'user': user,
        'name': ''
    }

    $scope.createGroup = function() {

        $http.post('api/user/'+$scope.sub+'/group', $scope.newGroup)
            .then(function(data) {
                $state.go($state.current, {}, {reload: true}); //second parameter is for $stateParams

                $uibModalInstance.close();
            }
        );
    }
}

// Controller for Modal Instance of Add Transmitter
function MICaddTransmitter($scope, $http, $state, $uibModalInstance, user) {
    $scope.newTransmitter = {
        'user': user,
        'code': ''
    }

    $scope.addTransmitter = function() {

        $http.put('api/transmitter/'+$scope.newTransmitter.code, $scope.newTransmitter)
            .then(function(data) {
                $state.go($state.current, {}, {reload: true}); //second parameter is for $stateParams

                $uibModalInstance.close();
            }
        );
    }
}

所有这些在我的 localhost (Mac) 上都可以正常工作,但是当上传到我的 Server (Ubuntu) 时会抛出这个错误

angular.js:12477Error: [$injector:unpr] Unknown provider: 3Provider <- 3
  http://errors.angularjs.org/1.4.7/$injector/unpr?p0=3Provider%20%3C-%203
  at angular.js:68
  at angular.js:4289
  at Object.getService [as get] (angular.js:4437)
  at angular.js:4294
  at Object.getService [as get] (angular.js:4437)
  at ui-bootstrap-tpls.js:4056
  at Object.forEach (angular.js:350)
  at getResolvePromises (ui-bootstrap-tpls.js:4052)
  at Object.$modal.open (ui-bootstrap-tpls.js:4097)
  at Scope.TransModalController.$scope.openModal (TransModalController.js:26)

Angular 是 v1.4.7,ui.bootstrap 是 v0.14.3

为什么它在我的 Localhost 上有效,但在我的 Server 上无效?

【问题讨论】:

    标签: javascript angularjs modal-dialog angular-ui-bootstrap angular-bootstrap


    【解决方案1】:

    很可能是由于缩小,请参阅link 上的“缩小说明”部分

    【讨论】:

    • 不使用缩小。另外,无论如何都尝试了两个链接的解决方案;都没有用。
    • @fglaria 那你的错误信息为什么会引用 ui-bootstrap-tpls.min.js?那是 ui-bootstrap 库的缩小版。
    • 我的错,我正在使用 Gulp,由于这个错误,将源文件从缩小版本更改为非缩小版本,但没有更改输出文件,因此将其命名为 .min.js,但不是。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 2014-08-04
    • 2012-09-02
    • 2017-04-16
    • 2017-10-08
    相关资源
    最近更新 更多