I am getting a async error when trying to get a users profile data from firebase and then displaying it on the home page. I tried removing the async in the home.html this gets rid of the error but no data is being shown.
InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'
home.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database';
import { Profile } from './../../models/profile';
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
profileData: FirebaseObjectObservable<Profile>
constructor(private afAuth: AngularFireAuth, private afDatabase: AngularFireDatabase,
private toast: ToastController, public navCtrl: NavController, public navParams: NavParams) {
}
ionViewWillLoad() {
this.afAuth.authState.take(1).subscribe(data => {
if (data && data.email && data.uid) {
this.profileData = this.afDatabase.object(`profile/${data.uid}`)
}
else {
this.navCtrl.setRoot('LoginPage');
}
})
}
}
home.html
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<p>Username: {{(profileData | async)?.username}} </p>
<p>Date of Birth: {{(profileData | async)?.birthdate}} </p>
</ion-content>