Angular4_Bootstrap 模态框避免点击背景处关闭(ng-bootstrap)

this. modalService. open( this. chooseManagementDecisionOrOtherReasonModal, { backdrop: 'static', keyboard: false} ). result. then((result) => { console. log( result); if ( result === 'OK') { } }, (reason) => { console. log( reason); });


ngx-bootstrap的话是

  1. import { Component, TemplateRef } from '@angular/core';
  2. import { BsModalService } from 'ngx-bootstrap/modal';
  3. import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
  4.  
  5. @Component({
  6. selector: 'demo-modal-service-options',
  7. templateUrl: './service-options.html'
  8. })
  9. export class DemoModalServiceOptionsComponent {
  10. modalRef: BsModalRef;
  11. config = {
  12. animated: true,
  13. keyboard: true,
  14. backdrop: true,
  15. ignoreBackdropClick: false
  16. };
  17. constructor(private modalService: BsModalService) {}
  18.  
  19. openModal(template: TemplateRef<any>) {
  20. this.modalRef = this.modalService.show(template, this.config);
  21. }
  22.  
  23. openModalWithClass(template: TemplateRef<any>) {
  24. this.modalRef = this.modalService.show(
  25. template,
  26. Object.assign({}, this.config, { class: 'gray modal-lg' })
  27. );
  28. }
  29. }


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部