Angularjs 角度解析获取返回
Angularjs 角度解析获取返回,angularjs,Angularjs,m通过以下请求在工厂中生成: var m = $http({method: 'GET', url: JSONurl}); GET请求后的m控制台日志: 我需要抓取m的“数据:”它有我需要的数组[2]。如何仅使用数据数组创建一个新变量?如果您查看angularJS,就会发现您需要使用promise来获取数据。所以你想要的东西大致如下: $http({ method: 'GET', url: JSONurl }).then(function successCallback(respo
m
通过以下请求在工厂中生成:
var m = $http({method: 'GET', url: JSONurl});
GET请求后的m
控制台日志:
我需要抓取
m
的“数据:”它有我需要的数组[2]
。如何仅使用数据数组创建一个新变量?如果您查看angularJS,就会发现您需要使用promise来获取数据。所以你想要的东西大致如下:
$http({
method: 'GET',
url: JSONurl
}).then(function successCallback(response) {
//response has the data on a successful call
}, function errorCallback(response) {
//this response will have the error data on a failed call
});
如果您查看angularJS,就会发现您需要使用promise来获取数据。所以你想要的东西大致如下:
$http({
method: 'GET',
url: JSONurl
}).then(function successCallback(response) {
//response has the data on a successful call
}, function errorCallback(response) {
//this response will have the error data on a failed call
});
m.then(res=>res.data)
m.then(res=>res.data)