stop closing the modal by clicking backdrop or outside the modal stop closing the modal by clicking backdrop or outside the modal angular angular

stop closing the modal by clicking backdrop or outside the modal


As per the answer of @anshuVersatile, I understand we need to use some modal options.

Then I create a object of NgbModalOptions and pass it as second parameter of my open method and it works.

Code is as follows :

let ngbModalOptions: NgbModalOptions = {      backdrop : 'static',      keyboard : false};console.log(ngbModalOptions);const modalRef = this.modalService.open(NgbdModalContent, ngbModalOptions);

Here is the updated plunker.


Though it is late still it might be helpful for somebody else facing the issue:

 const config: ModalOptions = {                backdrop: 'static',                keyboard: false,                animated: true,                ignoreBackdropClick: true,                initialState: {                  data1: 'new-user',                  username: 'test'                }              };              this.bsModalRef = this.modalService.show(MyComponent, config);

initialState object is used to pass data to modal.


$modal.open({   // ... other options   backdrop  : 'static',   keyboard  : false});

While you creating your modal you can specify its behavior: