【问题标题】:How get 400 Bad Request in variable如何在变量中获得 400 Bad Request
【发布时间】:2015-05-29 22:06:44
【问题描述】:

我的 REST 得到了答案 - 结果 =

我想向使用 angularJS 的用户显示此错误。

我在控制器中有功能

 $scope.update = function (id) {
                Topic.get({id: id}, function (result) {
                    $scope.name = result;
                    $('#saveTopicModal').modal('show');
                    console.log(result);
                });
            };

请帮助 - 如何在某个变量中出错,然后显示该变量。 谢谢

【问题讨论】:

  • 什么等于id
  • id - 它的整数 - .get 方法

标签: javascript angularjs


【解决方案1】:

要访问错误,您必须按照角度 $resource API 的描述定义错误处理程序。

                    $scope.error = error;
$scope.update = function (id) {
                Topic.get({id: id}, function (result) {
                    $scope.name = result;
                    $('#saveTopicModal').modal('show');
                    console.log(result);
                }, function (error) {                        
                    console.log(error);
                    $scope.error = error;
                });
            };

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-26
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    相关资源
    最近更新 更多