javascript - 错误 : [$injector:unpr] Unknown provider: modalInstanceProvider <- modalInstance <- modalCtrl with the latest ui bootstrap

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

编辑 - 如下面的代码所示,模态将工作 - 我的问题是我在我的模态的 HTML 模板中包含了 ng-app 和 ng-controller,但是它们不包含在下面的问题中。

我有我的主 Controller 、模态 Controller 和我的模态模板 HTML

一切似乎都井井有条,我终生无法解决(或从 stackoverflow 中找出)为什么我一直收到 Error: [$injector:unpr] Unknown provider: modalInstanceProvider <- modalInstance <- modalCtrl错误。 顺便说一句 $modal现在已被删除,它是 $ubiModal现在。

主控:

var module = angular.module("app", ["agGrid", "ngAnimate", "ngSanitize", "ngDialog", "ui.bootstrap"])

module.controller("mainCtrl", ["$scope", "dataService", "$timeout", "dateFilter", "ngDialog", "$http", "$uibModal", function ($scope, dataService, $timeout, dateFilter, ngDialog, $http, $uibModal) {

$scope.open = function () {

    var uibModalInstance= $uibModal.open({
        templateUrl: "views/Modal.html",
        controller: "modalCtrl",
        show: true,
    })
};
}]);

我的模态 Controller :

module.controller("modalCtrl", ["$scope", "ngDialog", "dataService", "$uibModalInstance", function ($scope, ngDialog, dataService, $uibModalInstance) {

//do stuff

}]);

和我的 HTML 模板:

 <div id="loginModal" class="modal show" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" ng-click="closeThisDialog(); printArray()" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h1 class="text-center" style="text-align: center">Entities:</h1>
                </div>
                <div class="modal-body">

                    <div>
                        <div>
                            <input type="text" placeholder="Search" ng-model="entity">
                        </div>
                    </div>

                    <div ng-repeat="entity in entityArray | filter:entity">

                        <label>
                            <input style="float: left; margin-top: 5px" type="checkbox" ng-model="entityChecked" ng-change="getEntityFromModal(entity, entityChecked)" />
                            <span>{{entity}}</span>
                        </label>
                    </div>
                </div>
                <button ng-click="okButtonEntity();" >OK</button>
            </div>
        </div>
    </div>

最佳答案

$modalInstance 已更改(弃用)为带有最新的 ui Bootstrap (0.14.3) 的 $uibModalInstance。它也应该是旧版本的 $modalInstance

module.controller("modalCtrl", ["$scope", "ngDialog", "dataService", "$uibModalInstance", 
                        function ($scope, ngDialog, dataService, $uibModalInstance) {

Documentation

controller - a controller for a modal instance - it can initialize scope used by modal. Accepts the "controller-as" syntax in the form 'SomeCtrl as myctrl'; can be injected with $uibModalInstance

关于javascript - 错误 : [$injector:unpr] Unknown provider: modalInstanceProvider <- modalInstance <- modalCtrl with the latest ui bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33438018/

相关文章:

javascript - jQuery hide 不隐藏 vb.net/asp.net webform 中的任何内容

angularjs - Socket.io - 向不同权限级别的用户广播的策略

angularjs - Angular UI Bootstrap Alert 可关闭问题

javascript - 停止 Vimeo 嵌入 Jquery Infinite Carousel 中的上一个/下一个按钮

php - 使用 php 突出显示非常大的文件之间的差异

javascript - 如何以正确的方式组织我的 Marionette.js 应用程序?

html - 垂直对齐 :after pseudo element

Angularjs UI 路由器 : Incorrectly interpreting url path as paremeter in $urlRouterProvider

javascript - 无法在服务器 NodeJS 上的 Mongo 中创建用户(或基于自定义的角色)

javascript - RequireJS 文本插件和变量连接字符串