menu

Ionic Popup


Ionic Popup Popups are basically used to draw user’s attention and get some information from the user or provide some information. Ionic Provides various popup alerts that can be used easily in any application.
Basically, there are – Basic Alerts, Prompt Alerts, Confirmation Alerts, Radio Alerts and Checkbox Alerts available in Ionic.
Here in this tutorial, we are going to explain how to create popup alert step by step with example and demo.


Ionic Popup | Alert | Prompt | Confirmation Alert | Example

Popup is basically dialog box that is used to show important message or information to User or It can can used
to get some input from user for example – Prompt box to enter username/password.

Now let us understand popup alert with example & demo –

  • 1. Basic Alerts
  • 2. Prompt Alerts
  • 3. Confirmation Alerts
  • 4. Radio Alerts
  • 5. Checkbox Alerts

Basic Alerts

  • 1. HTML Part – It contains the view part of basic alert.
  • 2. Script Part – This contains typescript code for the basic Alert.

Html Part : demo.html

So now add the following code to create button layout-

Ionic Popup Example: Html Part

Html contains the Layout part of the page, a button “Show Alert” is created to call function showAlert() which opens a basic alert, this function is defined in JavaScript Typescript – demo.ts file.

Script Part : demo.ts

It contains script resources to create Alert Box, showAlert() function is defined in this file which is triggered on Button click to open the Alert Box.

Ionic Popup Alerts Example: Script Part

Try it »

Import AlertsController, add in constructor and call create() method with parameters.
So we can see clearly only below things are required to create alerts.

1. importing AlertController.
2. calling it in constructor.

The output of above example will be something like this-

Ionic Alerts Example

Confirm Alerts | Confirmation Box | Yes | No

Confirmation Alert is used to get acceptance of user. Here is simple Confirmation Box

  • 1. HTML Part – It contains the Html Part.
  • 2. Script Part – It contains typescript code for the Confirmation Alerts.

Html Part : demo.html

Html template contains button to Call the Confirm Alert which calls showConfirmAlert Function –

Ionic Confirmation Box Alert Example: Html Part

Script Part : demo.ts

This contains definition of showConfirmAlert() function which is used to show confirm box –

Ionic Confirmation box Alerts Example: Script Part

Try it »

The output of above example will look something like this –

Ionic Confirmation Box Example

Prompt Alerts

This basically used to get user input for example- Enter Wifi password.

  • 1. HTML Part – It contains the Html Part.
  • 2. Script Part – It contains typescript code for the Prompt Alerts.

Html Part : demo.html

This contains button to Call the Prompt Alert box which calls prompt Function –

Ionic Prompt Alerts Example: Html Part

Script Part : demo.ts

Script Part contains the definition of prompt function –

Ionic Prompt box Alerts Example: Script Part

Try it »

The Above Example Will Output something like this –

Ionic Prompt Box Example & Demo

Radio Alerts

This shows radio options to user and user can select option using radio button.

  • 1. HTML Part – It contains the Html Part.
  • 2. Script Part – It contains typescript code for the Radio Alerts.

Html Part : demo.html

Html template contains button to which triggers radio alert Function –

Ionic Radio Popup Alert Box Example: Html Part

Script Part : demo.ts

It contains function definition

Ionic Radio Alert Popup box Example: Script Part

Try it »

Radio Alert output looks like this

Ionic Radio Alerts Example

Checkbox Alerts

It is used to provide options and user can select multiple options.

  • 1. HTML Part – It contains the Html Part.
  • 2. Script Part – It contains typescript code for the Checkbox Alerts.

Html Part : demo.html

Html template contains button to Call Checkbox alert Function –

Ionic Checkbox Alerts Box Example: Html Part

Script Part : demo.ts

This contains definition of showCheckboxAlert() function –

Ionic Checkbox Alert box Alerts Example: Script Part

Try it »

If you run the above example it will produce output something like this –

Ionic Checkbox Alert Box


User Ans/Comments

📖 Read More


    Advertisements