Reputation: 3791
In Angular 5 + Firebase (AngularFire) project i have service Current
, where i get current user data from Firebase RDB:
export class CurrentService {
public current;
constructor(
private authFb: AngularFireAuth,
private db: AngularFireDatabase
) {
this.isLoggedIn().pipe(
tap(user => {
if (user) {
this.current = this.db.object(`users/${user.uid}`)
.valueChanges()
} else {
this.current = null;
console.log("no")
}
})
)
.subscribe()
}
isLoggedIn() {
return this.authFb.authState.pipe(first())
}
}
And in view i want bind current
values:
{{ currService.current?.username }}
But its return null
. What is strange, becouse when i bind {{ (currService.current | async) | json }}
its return full object with fields and values in json format. What i did wrong?
Upvotes: 0
Views: 111
Reputation: 71911
You have to use the async
pipe as well:
{{ (currService.current | async)?.username }}
Upvotes: 1