未知提供商:$ uibModalInstanceProvider - 引导UI模式 [英] Unknown provider: $uibModalInstanceProvider - Bootstrap UI modal
本文介绍了未知提供商:$ uibModalInstanceProvider - 引导UI模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有UI引导模式有问题。
I have a problem with UI Bootstrap modal.
在一个控制器我有这样的:
In one controller I have this:
app.controller("tableCtrl",['$scope','$http','$uibModal','$log' ,function ($scope, $http,$uibModal,$log) {
$scope.open = function (size,selectedUser) {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller:'ModalInstanceCtrl',
size: size,
resolve: {
user: function () {
return selectedUser;
}
}
});
}]);
在另一个我有这样的:
app.controller('ModalInstanceCtrl',['$scope','$uibModalInstance','user', function ($scope, $uibModalInstance, user) {
$scope.user = user;
$scope.ok = function () {
$uibModalInstance.close();
};
}]);
myModalContent
是这样的:
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header"><h1>EDIT</h1></div>
<div class="modal-body">
{{patient.patient_id}}
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
</div>
</script>
我只叫 tableCtrl
HTML和调用打开
函数是这样的:
I only call tableCtrl
in HTML and call open
function like this:
<button class="btn btn-primary" ng-click="open('lg',patient)">Edit</button>
当我点击编辑按钮,我收到此异常:
When I click the edit button I receive this exception:
Unknown provider: $uibModalInstanceProvider <- $uibModalInstance
我看到这plunker 但它没有帮助我。
什么是错的?
推荐答案
我有同样的问题,所以从我的解决方案,这里是你如何能解决您的方案
I had the same problem, so from my solution here's how you could solve your scenario
app.controller("tableCtrl",['$scope','$http','$uibModal','$log' ,function ($scope, $http,$uibModal,$log) {
$scope.open = function (size,selectedUser) {
var uibModalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'myModalContent.html',
controller:function($uibModalInstance ,$scope,user){
$scope.ok = function () {
$uibModalInstance.dismiss('cancel');
};
},
size: size,
resolve: {
user: function () {
return selectedUser;
}
}
});
}]);
这篇关于未知提供商:$ uibModalInstanceProvider - 引导UI模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文