ionic modal example
Example 1: ion modal dismiss
export class ModalPage {
...
dismiss() {
// using the injected ModalController this page
// can "dismiss" itself and optionally pass back data
this.modalCtrl.dismiss({
'dismissed': true
});
}
}
Example 2: ionic modal controller
constructor(public modalCtrl: ModalController) {}
...
presentProfileModal() {
let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });
profileModal.present();
}
Example 3: ionic modal example
import { Component } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { ModalPage } from '../modal/modal.page';
@Component({
selector: 'modal-example',
templateUrl: 'modal-example.html',
styleUrls: ['./modal-example.css']
})
export class ModalExample {
constructor(public modalController: ModalController) {
}
async presentModal() {
const modal = await this.modalController.create({
component: ModalPage,
cssClass: 'my-custom-class'
});
return await modal.present();
}
}
Example 4: ionic create modal
import { Component } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { ModalPage } from '../modal/modal.page';
@Component({
selector: 'modal-example',
templateUrl: 'modal-example.html',
styleUrls: ['./modal-example.css']
})
export class ModalExample {
constructor(public modalController: ModalController) {
}
async presentModal() {
const modal = await this.modalController.create({
component: ModalPage
});
return await modal.present();
}
}
Example 5: ion modal toolbar
<ion-toolbar>
<ion-title>Pesquisar médicos</ion-title>
<ion-buttons slot="start">
<ion-button onclick="add_doc(null)">Cancelar</ion-button>
</ion-buttons>
</ion-toolbar>