我使用sweetalert 2进行删除,但是当我单击删除图标时,wealalert会出现,并且当我确认某项中的删除时,它不会删除,但是此后,下次我单击菜单中的删除图标相同的项目,该项目将被删除,然后出现sweetalert。
附言第一次从数组中删除项目
$scope.remove = function (i) {
// let r = confirm("Are you sure? Do you need to delete the keyword?");
// let r = false;
swal({
title: "Are you sure?",
text: "Once aaa deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
showLoaderOnConfirm: true
})
.then((willDelete) => {
if (willDelete) {
// console.log("r2success" + r);
// console.log("r1success" + r);
// r = true;
$scope.taggingRows.splice(i, 1);
// console.log(" i " + i + " & " + "r " + r);
$scope.taggingRowsAct.splice(i, 0);
swal("Your file has been deleted!", {
icon: "success",
})
} else {
swal("Your file was not deleted!");
console.log("r1canceled" + r);
r = false;
console.log("r2canceled" + r);
}
});
答案 0 :(得分:0)
使用第3方非角度库时,需要使用$scope.$apply()
更新范围绑定:
.then((willDelete) => {
if (willDelete) {
$scope.taggingRows.splice(i, 1);
// console.log(" i " + i + " & " + "r " + r);
$scope.taggingRowsAct.splice(i, 0);
$scope.$apply();
swal("Your file has been deleted!", {
icon: "success",
})
} else {
swal("Your file was not deleted!");
console.log("r1canceled" + r);
r = false;
console.log("r2canceled" + r);
}
});