confirm value is not returning from sweet alert service

后端 未结 1 1733
春和景丽
春和景丽 2021-01-07 07:46

Had created sweet alert as seperate service and Im injecting that inro my service

This is the sweet alert service

(function(){
    \'use strict\';
           


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 08:31

    I think you should change implementation of sweeet alert confirm box. The way confirm method of sweet alert implement, you need to pass pass a callback to execute to confirm method and execute over there.

    confirm: function(title, message, callback) {
      swal({
        title: "Are you sure?",
        text: "You will not be able to recover this imaginary file!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: '#DD6B55',
        confirmButtonText: 'Ok',
        cancelButtonText: "Cancel",
        closeOnConfirm: true,
        closeOnCancel: true
      },
      function(isConfirm) {
          callback(isConfirm)
      });
    };
    

    Controller

    $scope.updateRow = function(row, event) {
      vm.clear();
      SweetAlert.confirm('Are you sure?', null, function(isConfirmed) {
        if (isConfirmed) {
          vm.save(row.entity);
        } else {
          event.preventDefault();
        }
      });
    };
    

    0 讨论(0)
提交回复
热议问题