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的话是
- import { Component, TemplateRef } from '@angular/core';
- import { BsModalService } from 'ngx-bootstrap/modal';
- import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
- @Component({
- selector: 'demo-modal-service-options',
- templateUrl: './service-options.html'
- })
- export class DemoModalServiceOptionsComponent {
- modalRef: BsModalRef;
- config = {
- animated: true,
- keyboard: true,
- backdrop: true,
- ignoreBackdropClick: false
- };
- constructor(private modalService: BsModalService) {}
- openModal(template: TemplateRef<any>) {
- this.modalRef = this.modalService.show(template, this.config);
- }
- openModalWithClass(template: TemplateRef<any>) {
- this.modalRef = this.modalService.show(
- template,
- Object.assign({}, this.config, { class: 'gray modal-lg' })
- );
- }
- }
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
