1export class ModalPage {
2 ...
3 dismiss() {
4 // using the injected ModalController this page
5 // can "dismiss" itself and optionally pass back data
6 this.modalCtrl.dismiss({
7 'dismissed': true
8 });
9 }
10}
1import { Component } from '@angular/core';
2import { ModalController } from '@ionic/angular';
3import { ModalPage } from '../modal/modal.page';
4
5@Component({
6 selector: 'modal-example',
7 templateUrl: 'modal-example.html',
8 styleUrls: ['./modal-example.css']
9})
10export class ModalExample {
11 constructor(public modalController: ModalController) {
12
13 }
14
15 async presentModal() {
16 const modal = await this.modalController.create({
17 component: ModalPage,
18 cssClass: 'my-custom-class'
19 });
20 return await modal.present();
21 }
22}