Hello.
I suppose there much be something specific about this case, as it is suppose to work.
The problem is simple - i can’t open modal from the content of ion-tab
i have a google map in ion-tab
and trying to call a modal from the click at the google map marker.
here is the related code:
call itself:
export class MapMainTabPage {
@ViewChild('map') mapElement: ElementRef;
constructor(private modalCtrl:ModalController, private userData: UserData, private events: Events, private mapService: MapService, private condoService: CondoServiceProvider) {
}
ionViewDidLoad() {
if (this.userData.getLocation()){
this._setupMap()
}
else {
this.events.subscribe('user:location:set', ()=>{this._setupMap()})
}
console.log('ionViewDidLoad MapMainTabPage');
}
_setupMap(){
this.mapService.initializeMap(this.mapElement);
this.condoService.getCondoAllByCountry(this.userData.country_code).subscribe(data=>{
this.mapService.placeMarkers(data, this.callLocationItemsModal)
})
}
callLocationItemsModal(location_id){
console.log("callLocationItemsModal(), id: ", location_id);
let myModal = this.modalCtrl.create('MapLocationModalPage', {condoId: location_id});
myModal.present();
}
}
=> the callLocationItemsModal
called properly with the marker id passed into it.
But the modal throwing an error:
Uncaught TypeError: Cannot read property 'modalCtrl' of undefined
at webpackJsonp.251.MapMainTabPage.callLocationItemsModal (map-main-tab.ts:44)
what is wrong?