Angular SweetAlert2 Confirmation
This code updates the data for the app.
Library: angular
/*update data */
updateData(data:any) {
this.global.swal.fire({
title: '[APP NAME]',
text: "[MESSAGE]?",
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
}).then(async(result) => {
if (result.isConfirmed) {
this.loadingEvent(true);
try {
await this.service.updateData(data);
await this.getData();
this.global.swal.fire(
'[APPNAME]',
'[SUCCESS_MESSAGE]',
'success'
)
} catch (error) {
this.loadingEvent(false);
this.global.errorHandler(error);
}
}
})
}