我正在使用 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>