On one of my pages, when the user clicks the Delete button, an alert appears asking for confirmation. This action exists on more than one page, to avoid duplicate code, how can I reuse the method below? Should I move to some location, do some kind of include?
showConfirm(slidingItem: ItemSliding) {
const confirm = this.alertCtrl.create({
title: 'Deletar tarefa!',
message: '<strong>Atenção</strong>: Essa ação não tem como ser desfeita.',
buttons: [
{
text: 'Cancelar',
handler: () => {
slidingItem.close();
}
},
{
text: 'Deletar',
handler: () => {
slidingItem.close();
}
}
]
});
confirm.present();
}
This code is executed by clicking on the element:
<button ion-button color="danger">
<ion-icon name="delete"></ion-icon>
Deletar
</button>