sweetAlertCtrl.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 'use strict';
  2. /**
  3. * controller for ngSweetAlert
  4. * AngularJS wrapper for SweetAlert
  5. */
  6. app.controller('SweetAlertCtrl', ['$scope', 'SweetAlert', function ($scope, SweetAlert) {
  7. $scope.demo1 = function () {
  8. SweetAlert.swal({
  9. title: "Here's a message",
  10. confirmButtonColor: "#007AFF"
  11. });
  12. };
  13. $scope.demo2 = function () {
  14. SweetAlert.swal({
  15. title: "Here's a message!",
  16. text: "It's pretty, isn't it?",
  17. confirmButtonColor: "#007AFF"
  18. });
  19. };
  20. $scope.demo3 = function () {
  21. SweetAlert.swal({
  22. title: "Good job!",
  23. text: "You clicked the button!",
  24. type: "success",
  25. confirmButtonColor: "#007AFF"
  26. });
  27. };
  28. $scope.demo4 = function () {
  29. SweetAlert.swal({
  30. title: "Are you sure?",
  31. text: "Your will not be able to recover this imaginary file!",
  32. type: "warning",
  33. showCancelButton: true,
  34. confirmButtonColor: "#DD6B55",
  35. confirmButtonText: "Yes, delete it!"
  36. }, function () {
  37. SweetAlert.swal({
  38. title: "Booyah!",
  39. confirmButtonColor: "#007AFF"
  40. });
  41. });
  42. };
  43. $scope.demo5 = function () {
  44. SweetAlert.swal({
  45. title: "Are you sure?",
  46. text: "Your will not be able to recover this imaginary file!",
  47. type: "warning",
  48. showCancelButton: true,
  49. confirmButtonColor: "#DD6B55",
  50. confirmButtonText: "Yes, delete it!",
  51. cancelButtonText: "No, cancel plx!",
  52. closeOnConfirm: false,
  53. closeOnCancel: false
  54. }, function (isConfirm) {
  55. if (isConfirm) {
  56. SweetAlert.swal({
  57. title: "Deleted!",
  58. text: "Your imaginary file has been deleted.",
  59. type: "success",
  60. confirmButtonColor: "#007AFF"
  61. });
  62. } else {
  63. SweetAlert.swal({
  64. title: "Cancelled",
  65. text: "Your imaginary file is safe :)",
  66. type: "error",
  67. confirmButtonColor: "#007AFF"
  68. });
  69. }
  70. });
  71. };
  72. $scope.demo6 = function () {
  73. SweetAlert.swal({
  74. title: "Sweet!",
  75. text: "Here's a custom image.",
  76. imageUrl: "http://oitozero.com/img/avatar.jpg",
  77. confirmButtonColor: "#007AFF"
  78. });
  79. };
  80. }]);