【问题标题】:angularjs DELETE FUNCTION ask the client if he is sure to delete [duplicate]angularjs DELETE FUNCTION询问客户是否确定要删除[重复]
【发布时间】:2018-12-22 05:56:14
【问题描述】:

嘿,我有一个删除功能适用于 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);
            }
            );
};

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

【问题讨论】:

  • 使用ui.bootstrap.modal。但请注意,模态对话框会使错误率加倍,增加完成任务的时间,并且几乎被用户普遍鄙视。其他通知方式通常是可用的,应在可能和适当的情况下使用。 ref
  • Kamlesh 更容易 xD,但 ty!
  • Kamlesh 的方式更简单,但 George 的建议是更好的用户体验。
  • 我不明白乔治的建议 xD... 我想用引导程序设计确认方式。我如何使用它:S?

标签: angularjs angular-ui-bootstrap confirm


【解决方案1】:

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

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

【讨论】:

  • 从 Chrome 46.0 开始,此方法在 <iframe> 中被阻止,除非它的沙盒属性值为 allow-modal。请务必查看MDN Web API Reference - Window.confirm() 中的注释。
  • 如何使用属性值?允许模式?
猜你喜欢
  • 2014-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-20
  • 2013-04-18
  • 2011-09-09
相关资源
最近更新 更多