0
我有一個組件可以在Angular 2+應用程序中利用谷歌地圖。有沒有一種體面的方式可以將鏈接導入到標記的infowindow中,這會觸發組件中的方法?下面的(click)
是麻煩點。如果我想搞一個全局方法(希望避免這種方法),我可以換成onclick
。谷歌地圖InfoWindow - (點擊)觸發Angular 2功能
//Add directions if we have a current location
let additionalContent = "";
if(this.positionMarker){
additionalContent = `<br><a href='#' (click)='startNavigating(${marker.position.lat()}, ${marker.position.lng()})'>Directions</a>`;
}
let infoWindow = new google.maps.InfoWindow({
content: content + additionalContent
});
google.maps.event.addListener(marker, 'click',() => {
infoWindow.open(this.map, marker);
});