.controller('FrameCtrl', ['$scope','$state','$rootScope', '$stateParams',
function($scope, $state, $rootScope, $stateParams) {
console.log($rootScope); // all the data is there.
console.log($rootScope.activeAddress); // undefined
console.log($rootScope.activeRestaurant); // undefined
}])
I am trying to understand why, even though the $rootScope object holds both the activeAddress
and activeRestaurant
object, they are empty when I console.log()
them specifically.
In the controller of the previous state, I set these two objects using these two lines of code, if that makes a difference:
// Parse.com promise returns array of addresses after login.
$rootScope.activeAddress = data.addresses[0];
// After getting restaurant ID from activeAddress, copy object to activeRestaurant
$rootScope.activeRestaurant = $rootScope.aRestaurant;
In short, I want to know why $rootScope.activeAddress
and $rootScope.activeRestaurant
return undefined, even though they appear in the $rootScope parent object.
EDIT: Here is the markup from the HTML page of the previous state:
<button class="button button-block button-positive" ng-click="login()"
ui-sref="frame.menu({menu: 'appetizers'})">
LOG IN
</button>