Accessing ngx-bootstrap modals outside click event

To achieve what your asking for you can read the event backdrop-click once modal is showing and you click backdrop. Here’s a working fork.

config = {
  backdrop: true,
  ignoreBackdropClick: false

openModal(printTemplate: TemplateRef<any>) {
  this.modalRef =, this.config);
  this.modalRef.onHide.subscribe((reason: string | any) => {
    if(reason === 'backdrop-click') {
      this.myFunc(); // run your function here

Note: Tested on ngx-bootstrap 6.1.0, typings seems broken below versions but probably fixable by changing the typings.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top