I am trying to use a service to access the current user variable from another controller. Here is my code:
Service:
angular.module('app').factory('AuthService', function ($http) {
var currentUser;
});
Controller 1:
angular.module('app').controller('Signup', function ($scope, AuthService) {
AuthService.currentUser = "test@email.com"
});
Controller 2:
angular.module('app').controller('Login', function ($scope, AuthService) {
$scope.user = AuthService.currentUser;
});
View:
<body ng-controller="Login" ng-cloak>
<button class="btn btn-link navbar-btn pull-right">{{user}}</button>
</body>
From looking at dev tools within chrome I can see that "user" is undefined. Any thoughts?