Kątowy: Dostęp do wartości zasobu w kontrolerze

Jestem okropny w javascript i bardzo nowy w Angular, więc zrób to ze mną.

Mój serwer zwraca to:

{"latitude": 3.172398, "name": "Event", "longitude": 101.6739005}

services.js

var mapModule = angular.module('map.services', ['ngResource']);

mapModule.factory('Event', function($resource) {
    return $resource('/custom_api/get_event_details/:eventId/',
        {eventId: '@id'});
});

controller.js

function mapCtrl($scope, Event) {
    var eventDetail = Event.get({eventId: $scope.eventId});
    console.log(eventDetail);
    console.log(eventDetail.latitude);
}

Próbuję uzyskać dostęp do jsona zwróconego przez mój serwer przezeventDetail.latitude ale dostajęundefined.

W konsoliconsole.log(eventDetail) wygląda jak:

e {$get: function, $save: function, $query: function, $remove: function, $delete: function}
latitude: 3.172398
longitude: 101.6739005
name: "abc"
__proto__: e

rozumiemeventDetail jestresource instancja, ale jak mogę po prostu uzyskać wartości bezpośrednio?

Gdybym ustawił$scope.eventDetail w moim kontrolerze mógłbym uzyskać do niego dostęp{{ eventDetail.latitude }} w moim szablonie.

Jak u licha mam to zrobić w kontrolerze?

questionAnswers(1)

yourAnswerToTheQuestion