I'm trying to get the user.id of a user after successful login using Angular/Firebase then assign it into a global variable. Is that possible ?
I think the best way is to build a service to manage your users. A service is a singleton so it's a proper way to store and manage these types of data.
You can build something like this:
//... code of your service ..
Var currentUser={};
function login()
{
// ... Code of you login function including you auth method ...
if (user && !user.isAnonymous) {
currentUser.userid = user.uid;
}
}
function getCurrentUser(){
return currentUser;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With