I would like to create variables that will be accessible in all components of the Angular application.
I create a service that allows the user to connect, I would like to retrieve the user information at the time of connection and assign them in variables that can be accessible in all components.
As for console.log (data.val ())
it shows me that the data is well presented.
I use Angular 6.
recupInfo(){
firebase.auth().onAuthStateChanged((user) => {
if (user) {
var ref = firebase.database().ref('users/' + user.uid +
'/username').on('value',(data) =>
var username = data.val() ;
);
}
});
}