import { Injectable, Type } from '@angular/core'; import { NgbModal, NgbModalOptions, NgbModalRef, } from '@ng-bootstrap/ng-bootstrap'; @Injectable({ providedIn: 'root', }) export class AppModalService { constructor(private modalService: NgbModal) {} public modalRef: NgbModalRef | null = null; public open(component: Type): NgbModalRef { const options: NgbModalOptions = { animation: true, windowClass: 'custom-modal', backdrop: 'static', keyboard: false, }; this.modalRef = this.modalService.open(component, options); return this.modalRef; } public close(): void { this.modalService.dismissAll(); } }