【发布时间】:2018-01-14 17:35:18
【问题描述】:
我在这里使用 ngx-bootstrap 作为模态,因为我正在使用来自 ngx-bootstrap 网站的他的第一个模态示例。为什么我无法 2 打开我的模板这是我的代码
<button type="button" class="btn btn-primary" (click)="openModal.template()">Create template modal</button>
<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">×</span>
</button>
</div>
<div class="modal-body">
This is a modal.
</div>
</template>
Module.ts
import { ModalModule } from 'ngx-bootstrap';
imports: [AlertModule.forRoot(), ModalModule.forRoot()]
Component.ts
import { BsModalService } from 'ngx-bootstrap';
import { BsModalRef } from 'ngx-bootstrap/';
public modalRef: BsModalRef;
constructor( private modalService: BsModalService){}
openModal(template: TemplateRef<any>) {
debugger;
this.modalRef = this.modalService.show(template);
}
【问题讨论】:
标签: twitter-bootstrap typescript angular2-forms ngx-bootstrap