Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49184

Opening a ModalController view from action-sheet button is not working

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 49184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>