2

我正在使用 Angular-Strap 来提供我的模态框,但我在关闭模态框然后导航到另一个页面时遇到了问题。出于某种原因,如果我不使用 $location.path,我只能关闭模式,一旦我添加它,它就会关闭模式本身并导航到新页面,但灰色背景仍然存在。我一直在寻找回电,但我还没有想出一种方法来一起做这两个动作。

模态调用

var modal = $modal({
            template: '/Product/Delete',
            persist: true,
            show: false,
            backdrop: 'static',
            scope: $scope
        });

调用打开模态

$scope.confirmDeleteProduct = function () {
            $q.when(modal).then(function (modalEl) {
                modalEl.modal('show');
            });
        };

当他们在模式上点击删除时进行的调用

$scope.deleteProduct = function (id,dismiss) {
            //ProductSvc.deleteProduct(id).success(function ($resp) {
            dismiss();
            //$scope.hideDeleteModal = true;
            $location.path('product/');

            //});
            //$scope.products = _.without($scope.products, product);
        };

删除模态

<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
            <h4>Delete Product</h4>
        </div>
        <div class="modal-body">
            <p>Do you really want to delete the product <strong>{{product.Name}}</strong>?</p>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn" ng-click="dismiss()">Cancel</button>
            <button type="button" class="btn btn-primary" ng-click="deleteProduct(product.Id,dismiss);">Delete</button>
        </div>
    </div>
</div>
4

2 回答 2

7

托尼,我一直有同样的问题。现在,这感觉很脏,但我注意到在调用 $(modal).modal('hide') - 或切换 - 之后 .modal-backdrop 在位置更改后保留在屏幕上。所以,我这样做了:

$('#cancelModal').modal('toggle');
$('.modal-backdrop').remove();
$location.path('/');

一些类似的帖子建议使用 angular-strap 或 angular-ui bootstrap,但我现在不想朝这两个方向前进。

编辑: 用户界面引导

于 2014-01-09T16:00:09.527 回答
0

我也有这个问题。如果您使用 angular bootstrap 0.13.0,请尝试降级到 0.12.1。这为我解决了这个问题。

原因似乎是与 ngAnimate 1.4.2 不兼容https://github.com/angular-ui/bootstrap/issues/3633

于 2015-07-09T00:51:24.603 回答