角度控制器ctrlreg错误

时间:2017-05-19 19:12:28

标签: javascript angularjs

当我尝试打开模式对话框时,我收到了ctrlreg错误。我不认为这是一个错字,我认为控制器正在注册,但是当我在调试器中附加它时,我看不到模板文件。

这是控制器:

    (function () {
    angular.module('myAppName.controllers').controller('ConfirmationModalController', function ($scope, $uibModalInstance) {
        $scope.del = function () {
            $uibModalInstance.close(true);
        };
        $scope.keep = function () {
            $uibModalInstance.close(false);
        };
    });

})();

当我重新加载页面时会受到影响,因此我猜测它已被注册。

现在我将尝试创建对话框:

    function deleteObject(obj) {
    var modalInstance = $uibModal.open({
                    animation: true,
                    ariaLabelledBy: 'modal-title',
                    ariaDescribedBy: 'modal-body',
                    templateUrl: 'js/views/confirm_modal.tpl',
                    controller: 'ConfirmationModalController',
                    controllerAs: '$ctrl',
                    size: 'lg',
                    resolve: {
                        data: function () {
                            return $ctrl.data;
                        }
                    }
                });
    modalInstance.result.then(
                    function(obj)
                    {
                        $ctrl.data.objects = _.without($ctrl.data.objects, obj);
                        DataService.save($ctrl.data);
                        ObjectService.remove(object.id);
                    },
                    function () {
                        console.log("------------ERROR----------");
                    }
            );
}

编辑: 以下是我收到的错误消息:

Error: [$controller:ctrlreg] http://errors.angularjs.org/1.6.2/$controller/ctrlreg?p0=ConfirmationModalController
at http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:6:425
at $get (http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:92:395)
at http://localhost:8080/webjars/angular-ui-bootstrap/2.2.0/ui-bootstrap-tpls.min.js:8:29619
at http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:134:167
at m.$get.m.$eval (http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:148:47)
at m.$get.m.$digest (http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:145:92)
at m.$get.m.$apply (http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:148:341)
at l (http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:101:89)
at XMLHttpRequest.t.onload (http://localhost:8080/webjars/angularjs/1.6.2/angular.min.js:106:489) Possibly unhandled rejection: {}

0 个答案:

没有答案
相关问题