Convertigo Public Knowledge base

How to manage the Alert component buttons?

The Alerts are a great way to offer the user the ability to choose a specific action or list of actions. They also can provide the user with important information, or require them to make a decision.

In Ionic, an Alert's role property can only take one of the following values:

  • 'cancel': Adds a "Cancel" button to the alert.

  • 'backdrop': Adds a backdrop to the alert that prevents interactions with the underlying UI.

If you use a role that is not one of the above two, the role property will be undefined. This is because the role property is used internally by Ionic to determine the type of button to display on the alert.

In order to support custom roles you will have to lean on the Return value of @Options button property.

When drag and dropping the Alert component in your event component, it comes with a handy Directive component set to ‘Switch’ function to manage the ‘cancel’, ‘backrop’ and ‘default’ roles. To add more roles, use the Return value property to declare it and test it in the Switch Directive:

parent.out.role is used to manage the integrated ‘cancel’ and ‘backrop’ roles and parent.out.data is used to manage your custom roles.

If you want to see it in action in your Convertigo Studio, you can import the sample project from here:

alert=https://github.com/convertigo/c8oprj-sample-alert/archive/master.zip

 

(c) Convertigo 2023 https://www.convertigo.com