当点击了棱角分明的UI bootsrap模式的如何捕捉大背景下单击事件? [英] How to catch backdrop click event when clicked out of angular ui bootsrap modal?
问题描述
在我的应用程序,它使用 $ modal.open()
函数打开它使用其他页面作为模板的模式弹出。当单击该按钮,它显示的模式弹出罚款。如果我点击取消按钮,然后它被调用这项功能,同时做工精细。
In my application, it is using $modal.open()
function to open a modal popup which is using another page as a template. While clicking the button, it is showing the modal popup fine. If I click the Cancel button then it is calling this function and working fine also.
$scope.cancel=function(){
});
但是,如果用户点击模式弹出之外,我们无法通过此code赶上该事件
But if the user clicks outside the modal popup, we are unable to catch that event by this code
$scope.dismiss=function(){
});
我如何赶上该事件?
How do I catch that event?
我见过AngularJS的很多文章,但无法找到一个解决方案。
I have seen many articles of AngularJS, but couldn't find a solution for this.
推荐答案
$ modal.open()
返回一个对象,一个承诺。您可以使用的承诺,虽然IT连锁,并在catch处理。当你点击外面的大背景下,它确实关闭
内部,它拒绝承诺。
$modal.open()
returns a object with a promise. You can use the promise and chain it though, and handle it in the catch. When you click on the backdrop outside, it does a dismiss
internally and it rejects the promise.
例如: -
var instance = $modal.open(...);
instance.result.then(function(){
//Get triggers when modal is closed
}, function(){
//gets triggers when modal is dismissed.
});
如果您在 $ modalInstance
注入的儿童在使用这个你能做到这一点那里。所以基本上而不是处理事件
这可以帮助你在与承诺的帮助下更高层次做到这一点。
If you are using this in the child where $modalInstance
is injected you could do that there as well. So basically rather than dealing with event
this helps you do it at a higher level with the help of promises.
这篇关于当点击了棱角分明的UI bootsrap模式的如何捕捉大背景下单击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!