2017-01-23 62 views
0

m符合下列要求工厂获取生成:角度解析获取返回

var m = $http({method: 'GET', url: JSONurl}); 
GET请求后 m

控制台日志:

console log of m

我需要抓住m的“data:”其中有我需要的Array[2]。我将如何创建一个只有数据数组的新变量?

+0

'm.then(res => res.data)'' – Phil

回答

3

如果你看一下angularJS docs for $http,你会发现你需要使用诺言来获取数据。所以你想要的东西沿线:

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