ion-alert-controller

Contents

Alert controllers programmatically control the alert component. Alerts can be created and dismissed from the alert controller. View the Alert documentation for a full list of options to pass upon creation.

async function presentAlert() {
  const alertController = document.querySelector('ion-alert-controller');
  await alertController.componentOnReady();

  const alert = await alertController.create({
    header: 'Alert',
    subHeader: 'Subtitle',
    message: 'This is an alert message.',
    buttons: ['OK']
  });
  return await alert.present();
}

Methods

create

Description

Create an alert overlay with alert options

Signature create(opts: AlertOptions) => Promise<HTMLIonAlertElement>

dismiss

Description

Dismiss the open alert overlay.

Signature dismiss(data?: any, role?: string | undefined, id?: string | undefined) => Promise<boolean>

getTop

Description

Get the most recently opened alert overlay.

Signature getTop() => Promise<HTMLIonAlertElement | undefined>