我的 Angular5 应用程序中有一个 component.hmtl,它有一个名为 markerClick 的函数,可以打开一个模式。在模态中,我想显示我在 markerClick 函数中发送的 item.lat 参数,但无法做到这一点,需要您的帮助。
首先是component.ts 代码,然后是下面的component.html 代码。
open(content, latTmp) {
this.modalService.open(content, latTmp).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
console.log(latTmp);
}
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<agm-map [latitude]=57.107118 [longitude]=12.2520907 [zoom]="4">
<ng-container *ngFor="let item of station">
<agm-marker [latitude]="item.Lat" [longitude]="item.Lng" (markerClick)="open(content, item.Lat)">
</agm-marker>
</ng-container>
</agm-map>
<!-- </ng-container> -->
<!-- <img width="100%" height="400" alt="World Map" src="assets\images\SyntronicWorldMap.gif"> -->
</div>
<ng-template #content let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Station Info</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>Test Hardware 1, sätt behörighet…</p>
<p>Test Hardware 2…</p>
**HERE I WANT TO DISPLAY ITEM.LAT PARAMETER SENT FROM THE MARKERCLICK FUNCTION!!!!!**
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="c('Close click')">Close</button>
</div>
</ng-template>