I am currently creating a new property in $rootScope and setting its value in one module.
$rootScope.test = 123;
I am then trying to reference this value later in a service function.
.factory("testFactory", function ($location, $http, $rootScope) {
/* .... */
return {
testFunction : function(){
console.log($rootScope);
console.log($rootScope.test);
},
/* .... */
When I view the console output in Chrome, I can see that the value of test is being set properly in the $rootScope object, but I am unable to reference using the $rootScope.test syntax. $rooScope.test simply returns undefined.
Is there any reason that you can't reference property values of $rootScope in services? Or am I attempting to retrieve this value improperly?
UPDATE - I have created a Plunker that demonstrates the issue that I am running into. http://plnkr.co/edit/ePEiYh