Google map is integrated the javascript way and I want to call a angular2 function inside an infowindow like the following code. Take a look at infoContent
for the
Here is my solution. First, I set id to button in info window. After that, I caught 'domready' event for info window which means: all the HTML has been received and parsed by the browser into the DOM tree which can now be manipulated. And then with getElementById accessed to button and add event 'click'. Here you can call your function defined in ts file.
const infoWindowContent = '' + community.typeOfCommunity + '
' +
'' + community.address.name + ' ' + community.streetNumber + ', ' + community.city + '
' +
'Manager: ' + community.manager.fullName + '
' +
'';
const infoWindow = new google.maps.InfoWindow({
content: infoWindowContent
});
marker.addListener('click', () => {
infoWindow.open(this.map, marker);
});
infoWindow.addListener('domready', () => {
document.getElementById("infoWindowButton").addEventListener("click", () => {
this.myFunction();
});
});