Sweet Alert 2 code example
Example 1: sweetalert angular 8
npm install --save sweetalert2
Example 2: sweet alert 2 do action on confirm
Swal.fire({
title: 'Do you want to save the changes?',
showDenyButton: true, showCancelButton: true,
confirmButtonText: `Save`,
denyButtonText: `Don't save`,
}).then((result) => {
if (result.isConfirmed) {
Swal.fire('Saved!', '', 'success')
} else if (result.isDenied) {
Swal.fire('Changes are not saved', '', 'info')
}
});
Example 3: switch alert
swal({
title: "Good job!",
text: "You clicked the button!",
icon: "success",
button: "Aww yiss!"
});
Example 4: sweet alert
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
Example 5: sweetalert2
$ npm install sweetalert2
Example 6: sweet alert 2
swal("Thank You!", "You clicked the button!", "success");