我的应用程序中有两个ngx bootstrap模态,并且我正在使用指令方式打开关闭模态。现在,当我按下Esc键或从父模式中单击关闭按钮时,如何显示确认框模式。
现在当我按下esc键时,父模态先关闭,然后显示子模态,有办法防止这种情况吗?
组件HTML-
<div class="modal fade" bsModal #addModal="bs-modal" [config]="addModalConfig" tabindex="-1" role="dialog" aria-labelledby="addModal" (onHide)="handler($event)">
<p>Parent Modal</p>
</div>
<div class="modal fade" bsModal #warningModal="bs-modal" tabindex="-1" role="dialog" aria-labelledby="dialog-static-name">
<p>Child Modal</p>
</div>
组件ts-
@ViewChild('addModal', { static: false }) addModal: ModalDirective;
@ViewChild('warningModal', { static: false }) warningModal: ModalDirective;
public addStoryModalConfig = {
backdrop: 'false',
animated : true
}
handler(event: ModalDirective) {
console.log();
if(this.addModal.dismissReason == 'esc'){
this.addStoryModal.config.keyboard = false;
this.warningModal.show()
}
}