Angularjs $http服务请求异常(is not a function)


Angular 1.6版本的$http服务时会抛出异常(.success is not a function)
因为1.6版本的Angular移除success和error,转而使用then和catch代替
请求返回的result的所含的属性为(如下图):其中data就是返回的数据。
result.data.Message是异常捕获的信息。

Angularjs $http服务请求异常(is not a function)_第1张图片

 $http.get(dataUrl).then(function (result) {
     $scope.data.products=result.data;
 }).catch(function (result) {
     $scope.data.error=result.data.Message;
 })

你可能感兴趣的:(Angularjs $http服务请求异常(is not a function))