Dialogs
EOL Notice
Dialogs will reach its end-of-life on July 1, 2024, and will no longer receive updates or support. Please see Support Policy for additional information.
The Dialogs plugin provides access to customize the native device dialogs.
Installation
If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.
Next, install the plugin:
- Capacitor
- Cordova
npm install @ionic-enterprise/dialogs
npx cap sync
ionic cordova plugin add @ionic-enterprise/dialogs
Index
Classes
Interfaces
Classes
Dialogs
usage:
import { Dialogs } from '@ionic-enterprise/dialogs/ngx';
constructor(private dialogs: Dialogs) { }
...
this.dialogs.alert('Hello world')
.then(() => console.log('Dialog dismissed'))
.catch(e => console.log('Error displaying dialog', e));
interfaces: DialogsPromptCallback
alert
▸ alert(message: string
, title?: string
, buttonName?: string
): Promise
<any
>
Shows a custom alert or dialog box.
Parameters:
Name | Type | Description |
---|---|---|
message | string | Dialog message. |
Optional title | string | |
Optional buttonName | string |
Returns: Promise
<any
>
Returns a blank promise once the user has dismissed the alert.
beep
▸ beep(times: number
): void
The device plays a beep sound.
Parameters:
Name | Type | Description |
---|---|---|
times | number | The number of times to repeat the beep. |
Returns: void
confirm
▸ confirm(message: string
, title?: string
, buttonLabels?: string
[]): Promise
<number
>
Displays a customizable confirmation dialog box.
Parameters:
Name | Type | Description |
---|---|---|
message | string | Dialog message. |
Optional title | string | |
Optional buttonLabels | string [] |
Returns: Promise
<number
>
Returns a promise that resolves the button index that was clicked, or 0 if the user has dismissed the dialog by clicking outside the dialog box. Note that the index use one-based indexing.
prompt
▸ prompt(message?: string
, title?: string
, buttonLabels?: string
[], defaultText?: string
): Promise
<DialogsPromptCallback>
Displays a native dialog box that is more customizable than the browser's prompt function.
Parameters:
Name | Type |
---|---|
Optional message | string |
Optional title | string |
Optional buttonLabels | string [] |
Optional defaultText | string |
Returns: Promise
<DialogsPromptCallback>
Returns a promise that resolves an object with the button index clicked and the text entered
Interfaces
DialogsPromptCallback
DialogsPromptCallback:
buttonIndex
● buttonIndex: number
The index of the pressed button. (Number) Note that the index uses one-based indexing, so the value is 1, 2, 3, etc.
input1
● input1: string
The text entered in the prompt dialog box. (String)