Closed Rouche closed 7 years ago
Same problem as the finally. It can be taken care of by client with .finally().then(angular. noop, angular. noop);
@Rouche can you explain how to fix it more clearly or send a link for fixing example. I experience the similar bug when clicking outside of the Modal to close Modal.
Maybe its not the same problem, us, was because we used finally()
on window.
Here is the complete code (See fix on the last line finally()):
var instanceBootstrap: ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open({
templateUrl: url,
controller: myCont,
resolve: {
model: function() {
return model;
}
},
keyboard: options.closeOnEscape,
scope: myScope,
windowClass: myCss
});
instanceBootstrap.result.finally(
(): void => {
myScope.$destroy();
}
}
).then(angular.noop, angular.noop);
a better solution: https://github.com/angular-ui/ui-router/issues/2889#issuecomment-237521045
@hikalkan:
Is there a more elegant way to fix this without adding .result.finally(angular.noop).then(angular.noop, angular.noop)
at every $uibModal.open()
call? Looks like a dirty hack, specially if you have a few modal calls
Try not using finally()
Finally creates a new promise, you have no choice to catch it, even if you have nothing to do, and you probably have nothing to do in a modal's finally.then()
.
Calling open without using finally wont give you the error.
It does for me. Pressing "esc" logs the error on console. This is how I call the modal:
$uibModal.open({
templateUrl: "views/layout/modals/audienceList.modal.client.view.html",
controller: "AudienceListModalController",
size: "lg"
})
Chaining .result.finally(angular.noop).then(angular.noop, angular.noop)
to the open method fix the issue for me.
Well, its not perfect for sure. But you can wrap it in another service so you dont need to repeat the code everywhere.
Bug description:
Closing a modal with ESC end up with "Possibly unhandled rejection: escape key press"
$modalStack.dismiss(modal.key, 'escape key press');
created a rejected promise that is not catched.here
Version of Angular, UIBS, and Bootstrap
Angular: 1.6.1
UIBS: 2.2.0
Bootstrap: 3.3.7