How do I access the currentUser email of AngularFireAuth? #2784
Unanswered
intheRain07
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You should do as follow: @Component({
selector: 'app-root',
template: `
<div *ngIf="user$ | async as user">
<h1>Hello {{ user.displayName }}!</h1>
<h2>Hello {{ user.email }}!</h2>
<button (click)="logout()">Logout</button>
</div>
`,
})
class SomeComponent {
user$ = this.auth.user;
constructor(private readonly auth: AngularFireAuth) {}
} Take a look at https://github.com/angular/angularfire/blob/master/docs/auth/getting-started.md |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am a beginner of angular firenase.
After login, the currentUser is still null unless I use await and async, which disable accessing the currentUser in constructor. But I really need to init some variables in the constructors by the currentUser. I find that this is an issue for the new version of firebase, since many previous tutorials simply access the currentUser and its properities.
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions