隐藏时从Dom中删除/删除的Ngx Bootstrap模板模态

时间:2017-08-29 12:56:43

标签: javascript html angular ngx-bootstrap

import { Component, TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class';

@Component({
  selector: 'demo-modal-service-static',
  templateUrl: './service-template.html'
})
export class DemoModalServiceStaticComponent {
  public modalRef: BsModalRef;
  constructor(private modalService: BsModalService) {}

  public openModal(template: TemplateRef<any>) {
    this.modalRef = this.modalService.show(template);
  }
}

创建模板模式

<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">
    This is a modal.
  </div>
</template>

http://valor-software.com/ngx-bootstrap/#/modals#directive-section

嗨,如上所示,使用模板创建模态会在隐藏模板时对其进行销毁。然而;我不想被隐藏。那是因为,我使用模态从列表中多次选择一些属性。因此,每次,我都要加载模态。这会导致性能问题。因此,有没有办法阻止它从dom中删除模态。

0 个答案:

没有答案