0
내 $ resource Venue 개체에 $ scope.lat 및 $ scope.lng를 사용하려고하므로 REST 통신은 항상 위치의 컨텍스트에있게됩니다. 그들은 HenriettaCtrl에 정의하기 전에 그들이 $ rootScope에서 전달되고 있는지 어떻게 알 수 없다거나 심지어 전혀에서 전달되는 경우 :
henriettaApp = angular.module('henriettaApp', ["ngResource"])
henriettaApp.factory "Venue", ["$resource", "$rootScope", ($resource, $rootScope) ->
console.log($rootScope.lat)
console.log($rootScope.lng)
$resource("/venuesNear/:id",{lat:$rootScope.lat,lng:$rootScope.lng,id:"@id"}, {update: {method:"PUT"}})
]
@HenriettaCtrl = ["$scope", "Venue", ($scope, Venue) ->
saveLocation = (position) ->
$scope.lat = position.coords.latitude
$scope.lng = position.coords.longitude
console.log($scope.lat)
$scope.streams = Venue.query()
navigator.geolocation.getCurrentPosition saveLocation
]
최고 'Venue 서비스'와'컨트롤러'를 의존성으로 – charlietfl