简体   繁体   English

ngx-bootstrap 模态内的 ngx-bootstrap 模态

[英]ngx-bootstrap modal inside a ngx-bootstrap modal

I'm developing an Angular application.我正在开发一个 Angular 应用程序。 I have an ngx-bootstrap modal which in turn is launched from a "parent" bootstrap modal.我有一个ngx-bootstrap模态,它又是从“父”引导模态启动的。 that is, it's a modal nested in another modal.也就是说,它是嵌套在另一个模态中的模态。

The line of code to close the modals is: this.bsModalRef.hide() .关闭模态的代码行是: this.bsModalRef.hide()

The thing is that it works perfectly when I click a button that triggers a function that executes that line of code, but, the big problem is when I execute the same line of code to close the child modal This one closes, but the parent modal loses the ability to close , even if hit the Close button which executes this line of code that closes the modal.问题是,当我单击一个按钮触发执行该行代码的函数时,它可以完美运行,但是,最大的问题是当我执行同一行代码以关闭模态时这个关闭了,但是模态失去了close的能力,即使点击了执行关闭模态的这行代码的Close按钮。

this is the button that closes the first ("parent") BsModalRef modal:这是关闭第一个(“父”)BsModalRef 模式的按钮:

 <button class="btn btn-oval btn-sm ml-2"
        (click)=" closeModal()"
        type="button">
        Close
      </button>

this is the function in the .ts file that makes the "Close" button closes the first modal:这是 .ts 文件中的函数,它使“关闭”按钮关闭第一个模式:

  closeModal() {
    this.bsModalRef.hide();
  }

Now, second modal also must have an option to close it and return to the previous modal, as in the first modal that also has a close button that also executes this to return to the main screen:现在,第二个模态也必须有一个选项来关闭它并返回到前一个模态,就像在第一个模态中一样,它也有一个关闭按钮,它也执行此操作以返回主屏幕:

closeModal() {
    this.bsModalRef.hide();
  }

And effectively it closes the second modal, but when trying to close the first modal to return to the very main screen, this Close button stop working and there is no way to close it.它有效地关闭了第二个模式,但是当尝试关闭第一个模式以返回到主屏幕时,此关闭按钮停止工作并且无法关闭它。

Why is this happening?为什么会这样? Any suggestion?有什么建议吗?

Thanks.谢谢。

问题是您在子组件和父组件 BsModalRef 命名中使用“bsModalRef”名称,将其中一个更改为不同的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM