在标记上单击以显示模态窗口。
我的代码:
google.maps.event.addListener(this.marker,'click', (marker)=> {
openModal();
});
openModal() {
this.modalService.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
我尝试在addeventListener中包含open方法,说明了内容id。我的模态窗口的起点是标记点击。
HTML CODE
<h4>{{title}}</h4>
<div id="dvMap" style="width:900px;height:600px;"></div>
<ng-template #content let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Modal title</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="c('Close click')">Close</button>
</div>
</ng-template>
也是这样尝试
<div id="dvMap" (click)="openModal()" style="width:900px;height:600px;"></div>
将此获取错误添加为“未定义openModal”。
http://plnkr.co/edit/LITQXFzZE7ETnTSH9nSP?p=preview使用此plunkr代码作为参考并使用ng-bootstrap。