Is there a way I can call a function after a modal window got called (no matter if it happened with a button or by clicking on the backdrop)
var dialog, options;
Angular 1.2 supports promises with a finally(callback):
dialog.result.finally(function() { alert('clean up resources'); });
Check out the working plunker here.