gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 14:51:05 25 4
gpt4 key购买 nike

编辑 - 如下面的代码所示,模态将工作 - 我的问题是我在我的模态的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com