import { Component, TemplateRef } from '@angular/core'; import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; @Component({ // eslint-disable-next-line @angular-eslint/component-selector selector: 'demo-modal-service-nested', templateUrl: './service-nested.html' }) export class DemoModalServiceNestedComponent { modalRef?: BsModalRef | null; modalRef2?: BsModalRef; constructor(private modalService: BsModalService) {} openModal(template: TemplateRef) { this.modalRef = this.modalService.show(template, { id: 1, class: 'modal-lg' }); } openModal2(template: TemplateRef) { this.modalRef2 = this.modalService.show(template, {id: 2, class: 'second' }); } closeFirstModal() { if (!this.modalRef) { return; } this.modalRef.hide(); this.modalRef = null; } closeModal(modalId?: number){ this.modalService.hide(modalId); } }