加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 如何以编程方式关闭ng-bootstrap模式?

发布时间:2020-12-17 07:57:27 所属栏目:安全 来源:网络整理
导读:我有一个模态: template #warningModal let-c="close" let-d="dismiss" div class="modal-header" button type="button" class="close" aria-label="Close" (click)="d('Cross click')" span aria-hidden="true"times;/span /button h4 class="modal-title"
我有一个模态:
<template #warningModal let-c="close" let-d="dismiss">
  <div class="modal-header">
    <button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
      <span aria-hidden="true">&times;</span>
    </button>
    <h4 class="modal-title">Warning</h4>
  </div>
  <div class="modal-body">
      The numbers you have entered result in negative expenses.  We will treat this as $0.00.  Do you want to continue?
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" (click)="c('Close click')">No</button>
    <button type="button" class="btn btn-secondary" (click)="submit()">Yes</button>
  </div>
</template>

每当我单击是,我希望它调用一个函数并关闭它自己.
在我的控制器中,我有@ViewChild(‘warningModal’)警告;并且在submit()中,我有this.warning.close();,但是我得到这个.每当我点击是时,warning.close都不是函数.

我如何让它以我想要的方式工作?

如果您正在使用 https://ng-bootstrap.github.io/(如您的问题所示),事情非常简单 – 您只需打开一个模态并从模板(如代码中)或编程方式(通过在返回的NgbModalRef类上调用close()方法) ).

以下是显示此操作的最小示例:http://plnkr.co/edit/r7watmQuyaUQ8onY17Z1?p=preview

您可能要么混淆不同的库,要么可能还有更多问题,但很难根据所提供的信息进行更多说明.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读