从文档:
重要的是要意识到调用$ resource对象方法会立即返回空引用(对象或数组取决于isArray)。从服务器返回数据后,将使用实际数据填充现有引用。
因此,除非将其放入回调函数中,否则您的日志记录将无法正常工作,如下所示:
function mapCtrl($scope, Event) { Event.get({eventId: $scope.eventId},function(eventDetail){ //on success callback function console.log(eventDetail); console.log(eventDetail.latitude); });}如果您由于某种原因不想使用a
resource,可以使用该
$http服务:
$http.get(url).then(function(response){console.log(response.data);});


