Call callback function on esc in Angular UI Bootstrap's modal

I'm using a modal of Angular UI Bootstrap that can be closed via a Cancel button or via ESC. As I have to do some cleaning when it closes, I've written the 'cancel' method in the scope, but this is only called when clicking this Cancel button, how could I do to call this cleaning functions when it closes on ESC too?


When a modal is dismissed (either by pressing ESC or clicking on backdrop) a promise returned from the $ method call is rejected. So you can react on ESC press by adding error handler to the returned promise. This is illustrated in the example available from the demo page: (see this line: $'Modal dismissed at: ' + new Date());)

thanks @pkozlowski.opensource

i directly knew what to do :)

var modalWindow = ${
    windowClass: 'modal myKewlDialog',
    templateUrl: 'views/modals/myKewlModalTemplate.html',
    controller: 'myKewlModalController'

modalWindow.result.then(function (result) {
}, function (result) {

Need Your Help

Best non-flash upload component for web applications?

javascript jquery upload

I would like recommendations for upload scripts/components. My criteria: