I'm trying to use $scope.lat and $scope.lng in my $resource Venue object, so that REST communication will always be in the context of a location. I can't tell if they are being passed in under $rootScope before they are defined in HenriettaCtrl or if they are even being passed in at all:
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
]
$rootScope will propagate down to $scope, but properties set on $scope will not propagate up to $rootScope.
You may need to use events to get the result you want, like the accepted answer to this question: AngularJS multiple uses of Controller and rootScope