import { Component, TemplateRef } from '@angular/core'; import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; @Component({ 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, { class: 'modal-sm' }); } openModal2(template: TemplateRef) { this.modalRef2 = this.modalService.show(template, { class: 'second' }); } closeFirstModal() { if (!this.modalRef) { return; } this.modalRef.hide(); this.modalRef = null; } }