我有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;
}
}
});
}]);