【发布时间】:2018-09-05 07:16:37
【问题描述】:
我们的应用程序中有一个标准模式。
<ng-template [ngIf]="true" #editDataModal>
<div class="modal-header">
<h5 class="modal-title">Edit Modal</h5>
<button type="button" class="close" aria-label="Close" (click)="onCancelClicked()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" #editDataModalBody>CUSTOM COMPONENT GOES HERE</div>
</ng-template>
我们希望能够传入一个自定义组件作为我们的 body。 ngx bootstrap 有没有办法做到这一点?
模态框似乎出现在主要内容之外,因此我们无法使用 ViewChild 找到它。
我们使用模态服务调用它。像这样:-
constructor(
private modalService: BsModalService
) { }
ngOnInit() {
this.modalConfig = {
ignoreBackdropClick: true
};
this.ModalRef = this.modalService.show(this.editModal, this.modalConfig);
}
【问题讨论】:
标签: angular6 ngx-bootstrap ngx-bootstrap-modal