I'm trying to use a cookie value in multiple places and within multiple controllers but I get error saying $rootScope is not defined
Here's the code:
capApp.controller('cookieCtrl', ['$scope','$cookies', function($scope, $rootScope, $cookies) {
// set variable for nav
$rootScope.cookieSet = $cookies.user_id;
}]);
capApp.controller('mainController', function($scope, $location) {
$scope.user_id = $rootScope.cookieSet; // set global var
});
Is there a better way to do this? Basically I want the cookie value available site wide