On my Ionic3 page, I am trying to trigger a modal open from within a click event function.
export class HomePage {
....
....
....
loadPos() {
var randomLocations = Microsoft.Maps.TestDataGenerator.getLocations(5, this.map.getBounds());
for (let i = 0; i < 5; i++) {
var pin = new Microsoft.Maps.Pushpin(randomLocations[i]);
this.map.entities.push(pin);
//Add a click event handler to the pushpin.
Microsoft.Maps.Events.addHandler(pin, 'click', this.pushpinClicked);
}
console.log("pins added")
pushpinClicked(e) {
HomePage.prototype.openModal()
}
openModal() {
const myModal = this.modal.create(ModalPage)
myModal.present()
}
}
While running openModal() works when triggered by an ionic-button click, it throws an error when triggered by a pushpin click:
cannot read property 'create' of undefined
How can I successfully open the modal from the click event?