It's a directive and a provider to use sweetalert in js code and in html.
these mudole use:
SweetAlert AngularJS wrapper that is https://github.com/oitozero/ngSweetAlert develop by: https://github.com/oitozero
and
ng-sweet-alert an angularjs directive that is https://github.com/tushariscoolster/ng-sweet-alert develop by: https://github.com/tushariscoolster
tnx for all.
if you need just a directive to use in html or need just fire sweetalret from your js code you can use one of tushariscoolster sn-sweet-alert directive or oitozero ngSweetAlert wrapper but when need both of them (like me) use ngSweetAlertFull.
Sweet Alert is a beautiful replacement for Javascript's "Alert".
https://github.com/Mehrdad-Dadkhah/ngSweetAlert/demo
or:
[http://oitozero.github.io/ngSweetAlert/](ngSweetAlert DEMO)
and
[http://tushariscoolster.github.io/ng-sweet-alert/](ng-sweet-alert DEMO)
- required:
AngularJS
sweetalert
- download the files
- Bower
- add
"ngSweetAlertFull": "latest"
to yourbower.json
file then runbower install
OR runbower install ngSweetAlertFull
- add
- Bower
- include the files in your app
SweetAlert.js
ngSweetAlertFull.js
ORsweet-alert.min.js
sweet-alert.css
jquery.min.js
when need to use directive (when use sweet-alert in html)
<link rel="stylesheet" type="text/css" href="../lib/sweet-alert.css"> <script src="../lib/jquery.min.js" type="text/javascript"></script> <script src="../lib/SweetAlert.js" type="text/javascript"></script> <script src="../lib/angular.min.js" type="text/javascript"></script> <script src="../src/ngSweetAlertFull.js" type="text/javascript"></script> <script src="./app.js" type="text/javascript"></script>
- include the module in angular (i.e. in
app.js
) -ngSweetAlertFull
angular.module("testApp", ['ngSweetAlertFull']);
use in js:
SweetAlert.swal({
title: "Are you sure?",
text: "Your will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function(){
SweetAlert.swal("Booyah!");
});
or use in html:
<a class="btn" style="background-color:blue" sweet-on-confirm="checkConfirm()" sweet-on-cancel="checkCancel()" name="login-submit" sweet-cancel-option="{{sweet.cancel}}" sweet-confirm-option="{{sweet.confirm}}" sweet-options="{{sweet.option}}" sweet-alert-tag >Try It</a>
you can see [https://github.com/Mehrdad-Dadkhah/ngSweetAlertFull/demo/index.html](demo file)
or
- in js doc: http://oitozero.github.io/ngSweetAlert/
- directive doc: http://tushariscoolster.github.io/ng-sweet-alert/