When click a button in googlemaps info window, i want to navigate login page. But in my codes click operation gives error like this: TypeError: Cannot read property 'router' of undefined
constructor(private router: Router) {}
Marker Codes
const marker = new google.maps.Marker({
position: latlng,
map: this.map,
icon: icon
});
Info Window
const contentString = '<h3>'+gorevliName+' ('+gorevliPoint+'/10)</h3>' +
'<p>Yetkinlik: '+gorevliAbility+'</p>' +
'<ion-button id = "request">Görevli Çağır!</ion-button>';
const infoWindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 400
});
Creating marker&InfoWindow and click listeners
marker.addListener('click', function() {
infoWindow.open(this.map, marker);
google.maps.event.addListenerOnce(infoWindow, 'domready', () => {
document.getElementById('request').addEventListener('click', ()=> {
this.router.navigate(['login']);//gives typeError
});
});
});