User Confirmation and Notification

Learn how to add confirmation and notification features in your application.

The way the code is currently written, deleting a student from the roster might be done accidentally, if the user clicks or taps on the wrong button in the action sheet. There is no warning or confirmation requested. Likewise, when a student is deleted, there is no indication that the action occurred (other than the name disappearing from the list). We will address both of these shortcomings in this lesson.

Delete confirmation

It is inconsiderate for an app to take a destructive action, without at least warning the user. It is better to ask the user for confirmation, and that is what we will do here. In the previous chapter, the handler for the Delete button simply calls the deleteStudent function. Instead, it would be better to get a confirmation first. We can get that confirmation using an IonAlert.

The IonAlert component

An IonAlert is a modal UI component that provides a simple warning to the user that something important is about to happen, and optionally provides a means to cancel it. Below is what I have in mind to implement the confirmation. As with all Ionic components, it renders with the appropriate look and feel on both Android and iPhone.

Get hands-on with 1200+ tech skills courses.