A super lightweight, "promising" Angular wrapper for SweetAlert, a beautiful replacement for Javascript's "Alert".
bower install nz-sweet-alert
- Include files in your app
- SweetAlert Javascript & CSS
nzSweetAlert.js
- include
nzSweetAlert
as a dependency (i.e. inapp.js
) - Inject
nzSwal
into a service, controller, etc, to use.
Use as directed on http://tristanedwards.me/sweetalert, with the exception of callbacks, which now use promises!
Simply put:
nzSwal({
title: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD4B39',
confirmButtonText: "Yes, do it!",
closeOnConfirm: false
})
.then(function() {
nzSwal('You did it!');
doStuffOnConfirm();
})
.catch(function() {
nzSwal('Cancelled :)');
doStuffOnConfirm();
});
Set global SweetAlert defaults (yes, you can do that!) like so:
window.swal.setDefaults({
title: '',
text: '',
type: null,
allowOutsideClick: false,
showCancelButton: false,
closeOnConfirm: true,
closeOnCancel: true,
confirmButtonText: 'OK',
confirmButtonColor: '#AEDEF4',
cancelButtonText: 'Cancel',
imageUrl: null,
imageSize: null,
timer: null
});
Happy Alerting!