Angularjs 即使在删除后,也会显示已删除的项目
我使用sweetalert 2进行删除,但当我单击删除图标时,会出现sweetalert,当我确认删除某个项目时,它不会删除,但此后,下次单击同一项目中的删除图标时,该项目会被删除,然后会出现sweetalert。Angularjs 即使在删除后,也会显示已删除的项目,angularjs,sweetalert2,Angularjs,Sweetalert2,我使用sweetalert 2进行删除,但当我单击删除图标时,会出现sweetalert,当我确认删除某个项目时,它不会删除,但此后,下次单击同一项目中的删除图标时,该项目会被删除,然后会出现sweetalert。 注意:第一次从数组中删除该项 $scope.remove = function (i) { // let r = confirm("Are you sure? Do you need to delete the keyword?"); // let r = fals
注意:第一次从数组中删除该项
$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);
}
});
使用第三方非角度库时,需要使用
$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);
}
});
阅读更多: