Hello, i have a googlemap, i wanna push to homepage using this.navCtrl.push(HomePage);
Here’s my code:
var infowindow = new google.maps.InfoWindow({
content:"<input type='button' id='clickableItem'value='consulter profile'>"
});
google.maps.event.addListener(infowindow, 'domready', () => {
//now my elements are ready for dom manipulation
document.getElementById('clickableItem').addEventListener("click",kebbab);
function kebbab(){
this.navCtrl.push(HomePage);
}
});
i tried to make an alert("azz"); instead of this.navCtrl.push(HomePage); and it worked, but its not working with this.navCtrl.push(HomePage);
Is there anyway to do that?
Firstly, I would say to you that you have many other options to achieve this in an “Angular way”.
But, as you asked for help in your way, I will try to help.
It looks like this will be undefined when you you’ll click on the button.
Why? Because kebab isn’t binded to this.
So 2 options:
use ngZone.run(() => { } )
bind the function to this.
The Angular way is by far the best solution you could have instead of import * as “google” from …
And the angular way is to provide components, injectables, pipes and templates: https://angular-maps.com just like Ionic do
not sur it will works while the domready event will be triggered asynchronously from the actual context.
But try it btw, I’m not sure on this one because arrow function should be executed in the called context…