2017-01-23 12 views
0

mは、以下の要求に工場内で生成されます戻るGET:角度解析は

var m = $http({method: 'GET', url: JSONurl}); 
GET要求の後 m

コンソールログ:私はm年代を取得する必要があり

console log of 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 
    });