Restrict ng-bootstrap modal from closing if clicked outside or ESC button

You need to set backdrop and keyboard properties on modalOptions object, not null:

modalOption: NgbModalOptions = {}; // not null!

// ...

openAddModal() {
    this.modalOption.backdrop = 'static';
    this.modalOption.keyboard = false;
    const modalRef = this.modalService.open(PremiumProtectionComponent,this.modalOption);
}

You can add the ngModelOptions directly.

openAddModal() {
    const modalRef = this.modalService.open(PremiumProtectionComponent,{
        backdrop: 'static',
        keyboard: false
    });
}

Tags:

Angular