ng2-bootstrap-modal
ng2-bootstrap-modal copied to clipboard
Close with ESC (Escape) key
Is it possible to close the dialog with the ESC key (keyboard)
+1 for adding that option
Please add this option , or tell me some workaround for this.
@Prashant3108
As a quick and dirty workaround solution you can add HostListener to your component.
Update the original confirm.component.ts example with the following
Import HostListener from angular core:
import { Component, HostListener } from '@angular/core';
Add @HostListener to your component Class:
export class ConfirmComponent extends DialogComponent<ConfirmModel, boolean> implements ConfirmModel {
....
....
....
@HostListener('document:keyup', ['$event']) handleKeyUp(event) {
if (event.keyCode === 27) {
this.close();
}
}
}
Is it possible to make it in a specific component of my project for example in a single modal?