【发布时间】:2015-06-04 20:22:24
【问题描述】:
我正在使用 angular-ui 来打开和关闭模式。当我用submit(object) 或dismiss(message) 关闭它时,对话框关闭,但屏幕仍然灰显,我无法访问我的应用程序。一些代码:
父控制器(相关部分):
$scope.deleteConfirm = function(toDelete) {
console.log(toDelete);
var modalObj = {
templateUrl: 'views/templates/delete.html',
controller: 'DeleteCtrl',
size: 'sm',
resolve: {
toDelete: function() {
return toDelete;
},
collection: function() {
return $scope.users;
}
}
}
var modalInstance = $modal.open(modalObj);
modalInstance.result.then(function (deletedItem) {
console.log(deletedItem);
});
};
父 html:
<button class="btn btn-danger btn-xs" ng-click="deleteConfirm(user)">X</button>
模态控制器:
.controller('DeleteCtrl', ['$scope', '$modalInstance', 'toDelete', 'collection', function ($scope, $modalInstance, toDelete, collection) {
$scope.toDelete = toDelete;
$scope.remove = function() {
collection.$remove(toDelete).then(function(ref) {
$modalInstance.close(ref);
});
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);
模态模板:
<div class = "ll-modal">
<div class="modal-header">
<h3 class="modal-title">Confirm Delete</h3>
</div>
<div class="modal-body">
Are you sure you want to delete this item? It will be gone forever.
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="remove()">Delete Permanently</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
【问题讨论】:
-
什么版本的角度和引导程序?你也在使用 ngAnmate 吗?
-
Angular 1.4,angular-bootstrap 0.12,我现在将 ngAnimate 设置为 false,正如你所建议的那样
-
酷...或回退到 1.3.x
标签: angularjs modal-dialog angular-ui-bootstrap