甜蜜警报不适用于取消按钮

时间:2015-04-24 09:07:45

标签: javascript angularjs bind sweetalert

我正在使用甜蜜警报库,我的取消按钮有问题。这是我的甜蜜警报代码:

sweetAlert({
        title: title,
        text: text + ' ' + courseList,
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: confirmButtonText,
        cancelButtonText: "Continue with purchase",
        closeOnConfirm: false,
        closeOnCancel: false,
        html: true
    },
    function(isConfirm) {
        if (isConfirm) {
            angular.forEach(repeatedCourses, function(repeatedCourse) {
                $rootScope.$apply(function() {
                    this.removeCoursePurchase(repeatedCourse);
                }.bind(this));
            }.bind(this));
            $rootScope.$broadcast('uncheckCheckboxes');
            swal("Deleted!", "Your purchase has been refreshed.", "success");
        } else {
            swal("Cancelled", "Your imaginary file is safe :)", "error");
        }
    }.bind(this));

当用户点击确认按钮时,工作正常,但如果点击取消按钮没有做任何事情,它不会出现“已取消”框,我不知道为什么!

1 个答案:

答案 0 :(得分:1)

删除附加到回调函数的.bind(this),它将起作用。