Angular UI Bootstrap 模态 [英] Angular UI Bootstrap modal
问题描述
我正在使用 Angular UI Bootstrap modal (ui.bootstrap.dialog) 并且我有背景:true &背景点击:真实.
I am using Angular UI Bootstrap modal (ui.bootstrap.dialog) and I have backdrop: true & backdropClick: true.
但是当用户点击离开模态时,我不仅要执行关闭而且要执行附加功能.
But when user clicks away from the modal, I want to perform not only close but additional functions.
我在查看源代码时认为我可以覆盖 Dialog.prototype._bindEvents,但没有成功.
I was looking at the source code thinking I could overwrite Dialog.prototype._bindEvents but have not had any luck doing it.
我也认为这可能是原始引导模式中的隐藏"事件,但我无法捕捉到这个事件.
I also think this might be 'hidden' event in original bootstrap modal, but I was not able to catch this event.
有没有办法定义一个在背景点击时执行的函数,以及如何去做.
Is there a way to do define a function to execute on backdrop click, and how would one go about it.
谢谢--MB
推荐答案
我知道这是一个老问题,但自从我来到这里并且后来找到了解决方案......
I know this is an old question, but since I got here and found a solution later...
您可以观看 'modal.closure' 事件,广播到模态范围,如下所示:
You can watch the 'modal.closing' event, broadcasted to the modal's scope, like this:
.controller('modalCtrl', function($scope, $modalInstance) {
$scope.$on('modal.closing', function(event, reason, closed) {
console.log('reason: ', reason);
});
})
第二个参数是原因(传递给 $close() 方法的任何内容).点击背景的原因是背景点击
The second parameter is the reason (whatever is passed to the $close() method). The reason when clicking the backdrop is backdrop click
这是一个有效的 plunker
这篇关于Angular UI Bootstrap 模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!