在angularjs 1.5.8中绑定json响应数组时浏览器中的根范围异常处理程序

问题描述 投票:0回答:1

enter image description here

enter image description here

响应即将发生,但在范围内绑定时,此行会在浏览器根范围异常中引发错误

//////获得税

$scope.BindTax = function () {
    debugger;`enter code here`
    $http({
        url: 'Bindtaxdetails',
        method: "GET",
        datatype: 'json',

    }).then(function (response) {
        $scope.lst_taxdetails = response.data;
    })
}
.net angularjs model-view-controller
1个回答
0
投票

$ http服务疑难解答

要记录任何错误消息,请添加.catch处理程序:

$scope.BindTax = function () {
    debugger;`enter code here`
    $http({
        url: 'Bindtaxdetails',
        method: "GET",
        ̶d̶a̶t̶a̶t̶y̶p̶e̶:̶ ̶'̶j̶s̶o̶n̶'̶,̶

    }).then(function (response) {
        $scope.lst_taxdetails = response.data;
    }).catch(function (errorResponse) {
        console.log(errorResponse.status);
        console.log(errorResponse);
        throw errorResponse;
    });
}

dataType属性是jQuery AJAX库的一部分,而不是$ http服务配置的属性。有关更多信息,请参阅AngularJS $http Service API Reference - Usage

通过使用angular.js库而不是angular.min.js,您将获得更好的错误消息。

© www.soinside.com 2019 - 2024. All rights reserved.