Angularjs 无法访问Google地理编码API响应对象

Angularjs 无法访问Google地理编码API响应对象,angularjs,resources,geocoding,Angularjs,Resources,Geocoding,我的第一条信息: 嗯,我想写一个有角度的天气温泉。 作为模型的一部分,我需要使用谷歌地理编码api获取位置Lat和Lon,所以我需要使用谷歌地理编码api。 使用$resource.get后,我成功地从google获取了该对象,但无法访问它。 这是我的密码: weatherApp.controller('forecastController'['$scope','location','$resource',function($scope,location,$resource){ $sco

我的第一条信息: 嗯,我想写一个有角度的天气温泉。 作为模型的一部分,我需要使用谷歌地理编码api获取位置Lat和Lon,所以我需要使用谷歌地理编码api。 使用$resource.get后,我成功地从google获取了该对象,但无法访问它。 这是我的密码:

weatherApp.controller('forecastController'['$scope','location','$resource',function($scope,location,$resource){
    $scope.toGoogle = location.toGoogle;
    $scope.resource = $resource('http://maps.googleapis.com/maps/api/geocode/json?');
    $scope.georesult = $scope.resource.get({address:$scope.toGoogle,Key:"somekey"})
   console.log(angular.fromJson($scope.georesult));
}]);
$scope.togogle只是一个var,其中包含需要转换为x和y的地址

问题是-我得到了预期对象的响应,但当我尝试使用以下对象访问它时:

    console.log(angular.fromJson($scope.georesult.results[0].geometry.location.lat));
我收到TypeError:无法读取未定义的属性“0” 请注意,我已经用Angular.fromJson将Json转换为常规对象


有什么建议吗?提前感谢。

需要在promise callback中访问它$资源是异步的。你能给出一个基于这个用例的例子吗?当然……$resource的文档有例子