angularjs DELETE FUNCTION询问客户是否确定要删除

时间:2018-07-13 20:02:41

标签: angularjs angular-ui-bootstrap confirm

嘿,我的删除功能适用于http:

$scope.RemoveWorker=function(workerid){
    $http.delete("/ShiftWeb/rest/admin/removeworker?id="+workerid)
            .then(function(response){$scope.removeworker=response.data;
            alert("Worker " + workerid + " Deleted");
            $state.reload()
            console.log(response.data);
            }, function(error) {
                alert(error.data);
            }
            );
};

任何人都知道我如何询问客户是否确定要删除它。如果他说不,那就不要删除它。 请帮助:)

1 个答案:

答案 0 :(得分:3)

您可以使用确认功能修改以下功能,在其中可以输入任何提示用户的消息

$scope.RemoveWorker=function(workerid){
    if(confirm("Do you really want to delete this record ?")){
        $http.delete("/ShiftWeb/rest/admin/removeworker?id="+workerid)
             .then(function(response){$scope.removeworker=response.data;
               alert("Worker " + workerid + " Deleted");
               $state.reload()
              console.log(response.data);
              }, function(error) {
                    alert(error.data);
             });
     }
};