微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 ngx-bootstrap 为模态自定义 css

如何解决使用 ngx-bootstrap 为模态自定义 css

文档 (https://valor-software.com/ngx-bootstrap/#/modals#service-custom-css-class) 说要使用

<button type="button" class="btn btn-primary" (click)="openModalWithClass(template)">Open modal with custom css class</button>
<br>
 
<ng-template #template>
  <div class="modal-header">
    <h4 class="modal-title pull-left">Modal</h4>
    <button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <div class="modal-body">
    Just a modal with a bunch of words inside,nothing serIoUs.
  </div>
</ng-template>

并在函数显示“模板”

openModalWithClass(template: TemplateRef<any>) {
    this.modalRef = this.modalService.show(
      template,Object.assign({},{ class: 'gray modal-lg' })
    );

但是我为模态创建了一个组件(太大以至于不能在同一个组件中)所以 html 中没有 #template,我如何从我的其他 html 组件中导入 #template id?

非常感谢!

解决方法

如果你试图从另一个组件打开一个模态组件,那么这是使用 ngx-bootstrap 的正确方法: https://valor-software.com/ngx-bootstrap/#/modals#service-component

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。