4

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

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));

当用户单击确认按钮时,工作正常,但如果单击取消按钮不执行任何操作,则不会出现“已取消”框,我不知道为什么!

4

1 回答 1

1

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

于 2016-05-10T06:14:05.557 回答