现在正在重写对话框类,但是为了快速和肮脏,您可以修改选项对象以接收要在关闭时调用的函数,在关闭原型中,如果该函数不为空,则调用该函数:
注意closeFn
var defaults = {
backdrop: true,
dialogClass: 'modal',
backdropClass: 'modal-backdrop',
transitionClass: 'fade',
triggerClass: 'in',
resolve:{},
closeFn:null, // added with null default
backdropFade: false,
dialogFade:false,
keyboard: true, // close with esc key
backdropClick: true // only in conjunction with backdrop=true
/* other options: template, templateUrl, controller */
};
在关闭原型中:
if (self.options.closeFn!==null) {
self.options.closeFn();
}
控制器:
function doSomething() {
alert('something');
}
$scope.opts = {
backdrop: true,
keyboard: true,
backdropClick: true,
template: t, // OR: templateUrl: 'path/to/view.html',
controller: 'TestDialogController',
closeFn: doSomething
};
我在这里模拟了这个:http://plnkr.co/edit/iBhmRHWMdrlQr4q5d1lH?p=preview