catching Angular Bootstrap UI $uibModal closed event after the modal was closed

我的未来我决定 提交于 2019-12-05 01:55:04
Srijith

Try this.

.open method returns a promise that could be chained with .closed which is one of the many properties of .open method.

I tested it and it shows the alert only after the modal has closed and not while it's 'closing'.

Refer the 'closed' under Return section here

var modalInstance = $uibModal.open({
    templateUrl: "myModalContent.html",
    controller: "termModalCtrl",
    windowClass: 'app-modal-window',
    resolve: {
        'params': function () { return id }
    }
}).closed.then(function(){
  window.alert('Modal closed');
});

here is the plunker http://plnkr.co/edit/yB3k8e3R3ZLQFQ6sfLYW?p=preview

Use modalInstance.result promise second callback to catch the closing event. I'm also getting exception 'Unable to get property 'then' of undefined or null reference' on .closed.then ,

 var modalInstance = $uibModal.open({
    templateUrl: "myModalContent.html",
    controller: "termModalCtrl",
    windowClass: 'app-modal-window',
    resolve: {
        'params': function () { return id }
    }
});

modalInstance.result
   .then(function (selectedItem) {
    //
   }, function () {
    //close callback
    console.info('modal closed');
   });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!