$ modalInstance对话框关闭,但屏幕仍为灰色且无法访问

com*_*y24 6 modal-dialog angularjs angular-ui-bootstrap

我正在使用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);
});
Run Code Online (Sandbox Code Playgroud)

};

父html:

<button class="btn btn-danger btn-xs" ng-click="deleteConfirm(user)">X</button>
Run Code Online (Sandbox Code Playgroud)

模态控制器:

.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');
};

}]);
Run Code Online (Sandbox Code Playgroud)

模态模板:

<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>
Run Code Online (Sandbox Code Playgroud)

PSL*_*PSL 14

当modal与1.4.x角度版本一起使用时,看起来有问题ng-animate.由于ng-animate在转换完成后只是懒惰地移除DOM元素,因此在该流程中存在某些缺陷.你可以通过在模态设置中关闭动画来快速修复它.在Github记录了一个问题,即ui bootstrap尚未完全正式支持1.4.x.

var modalObj = {
  templateUrl: 'views/templates/delete.html',
  controller: 'DeleteCtrl',
  size: 'sm',
  animation: false, //<-- Turn off
  resolve: {
    toDelete: function() {
      return toDelete;
    },
    collection: function() {
      return $scope.users;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

或者只是全局关闭它:

app.config(function($modalProvider) {
  $modalProvider.options.animation = false;
});
Run Code Online (Sandbox Code Playgroud)

更新

如果您按照上面提供的github链接,您可以看到它已在最新版本的ui bootstrap 修复,即升级0.13.3或更高版本将解决该问题.