I want to know about the ways of saving user info.
Many seniors have recommended using $cookieStore
, or Authentication
or etc.
But how about using $rootScope
?
My idea is when user has logged in, saving his/her id and password into $rootScope
.
(Naming like $rootScope.user_id = 'stupid';
)
Is this dangerous way?
I don't know whether this question is duplicated or not, but I couldn't find one talking about using $rootScope
.
.
.
UPDATE
My config is like below.
'root controller' can see every scopes, so even if I refreshed pages,
$rootScope value does not disappear.
$stateProvider
.state('root.login',{
url: '/login',
controller: 'LoginCtrl',
templateUrl: 'views/login.html'
})
.state('root.signup',{
url: '/signup',
controller: 'LoginCtrl',
templateUrl: 'views/signup.html'
})
.state('root.main',{
url: '/main',
controller: 'MainCtrl',
templateUrl: 'views/main.html',
})