I am working on a school project and I wanted to open a modal view from the action-sheet button but I do get this error below
TypeError: Cannot read property 'addMedicationModalCtrl' of undefined
but when I use ion-button out side the action-sheet, it works.
the snapshot of the sample code below
constructor(
private addMedicationModalCtrl: ModalController,
private actionSheetCtrl: ActionSheetController,
) { }
ngOnInit() {
}
addMedication() {
console.log("add medication");
this.addMedicationModalCtrl.create({
component: CreateMedicationComponent
}).then(modalEle => {
modalEle.present();
});
}
onTreatment() {
const actionSheet = this.actionSheetCtrl.create({
header: 'Treatment',
buttons: [
{
text: 'Medication',
role: 'medication',
handler: this.addMedication,
},
],
})
actionSheet.then(actionSheetEle => {
actionSheetEle.present();
});
}
1 post - 1 participant