nz-sweet-alert
v1.0.0
Published
A super lightweight, "promising" Angular wrapper for [SweetAlert](http://tristanedwards.me/sweetalert), a beautiful replacement for Javascript's "Alert".
Downloads
3
Readme
nzSweetAlert
A super lightweight, "promising" Angular wrapper for SweetAlert, a beautiful replacement for Javascript's "Alert".
Demo
Install
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.
Promises
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();
});
Tips
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!