Verifique a alteração da variável de serviço angular
export class UserService {
userDocumentReady: boolean = false; // initial value is "userdoc is not ready"
userDocObserver: Subject<boolean> = new Subject<boolean>(); // observing that bool
constructor(
public fireauth: AngularFireAuth,
public afs: AngularFirestore,
) {
// watch variable
this.userDocObserver.subscribe(value => this.userDocumentReady = value);
this.fireauth.authState
.subscribe(user => {
if (user) {
this.afs.doc(`/tooluser/${user.uid}`).snapshotChanges()
.subscribe(usr => {
if (usr.payload.data()) {
console.log(`got user object from database:`, usr.payload.data());
this.currentUser = usr.payload.data();
this.userDocObserver.next(true); // flip UserDocumentReady flag
Pwejar Hub