How to catch backdrop click event when clicked out of angular ui bootstrap modal?

前端 未结 4 1141
青春惊慌失措
青春惊慌失措 2021-02-05 05:55

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

4条回答
  •  不要未来只要你来
    2021-02-05 06:37

    $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.

    ex:-

    var instance = $modal.open(...);
    
     instance.result.then(function(){
      //Get triggers when modal is closed
     }, function(){
      //gets triggers when modal is dismissed.
     });
    

    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.

提交回复
热议问题