获取数据后在html上显示AngularFireList
我试图在html上显示AngularFireList获取数据后在html上显示AngularFireList,angular,firebase,ionic-framework,angularfire2,Angular,Firebase,Ionic Framework,Angularfire2,我试图在html上显示AngularFireList 从'@angular/core'导入{Component}; 从'ionic angular'导入{NavController}; 从'angularfire2/auth'导入{AngularFireAuth}; 从“angularfire2/database”导入{AngularFireDatabase,AngularFireList}; @组成部分({ 选择器:“页面配置文件”, templateUrl:'profile.html' })
从'@angular/core'导入{Component};
从'ionic angular'导入{NavController};
从'angularfire2/auth'导入{AngularFireAuth};
从“angularfire2/database”导入{AngularFireDatabase,AngularFireList};
@组成部分({
选择器:“页面配置文件”,
templateUrl:'profile.html'
})
导出类配置文件页面{
profileData:AngularFireList
构造函数(私有fire:AngularFireAuth、私有db:AngularFireDatabase、公共navCtrl:NavController){
this.fire.authState.subscribe(auth=>{
//订阅可观察到的
this.profileData=this.db.list(`profile/${auth.uid}`).valueChanges().subscribe(p=>{
控制台日志(p);
});
});
}
}
我可以用这段代码获得数据,但我想我不能使它等于profileData,所以我不能在屏幕上显示它
<ul *ngFor="let profile of profileData | async">
<li> {{ profile.username}}:{{ profile.msgnumber}} </li>
</ul>
- {{profile.username}:{{profile.msgnumber}
无需订阅valueChanges()。
请参见无需订阅valueChanges()。 请参见您的代码应该是
this.profileData = this.db.list<profileData>(`profile/${auth.uid}`).valueChanges();
this.profileData=this.db.list(`profile/${auth.uid}').valueChanges();
您的代码应该是
this.profileData = this.db.list<profileData>(`profile/${auth.uid}`).valueChanges();
this.profileData=this.db.list(`profile/${auth.uid}').valueChanges();
我也遇到了同样的问题,为了将来遇到此类错误的用户的利益,这应该是可行的
this.profileDataRef = this.db.list(`profile/${auth.uid}`);
this.profileData = this.profileDataRef.valueChanges();
HTML模板
<ul *ngFor="let profile of profileData | async">
<li> {{ profile.username}}:{{ profile.msgnumber}} </li>
</ul>
- {{profile.username}:{{profile.msgnumber}
我也遇到了同样的问题,为了将来遇到此类错误的用户的利益,这应该是可行的
this.profileDataRef = this.db.list(`profile/${auth.uid}`);
this.profileData = this.profileDataRef.valueChanges();
HTML模板
<ul *ngFor="let profile of profileData | async">
<li> {{ profile.username}}:{{ profile.msgnumber}} </li>
</ul>
- {{profile.username}:{{profile.msgnumber}
您在控制台上看到任何错误吗?不仅仅是控制台。您可以发布控制台中的内容吗。logdb结构类似于profile-authid-username、msgnumber。。。可能是因为authid?你能发布你在控制台中看到的json吗?Log你在控制台上看到任何错误吗?不仅仅是控制台。Log你能发布控制台中的内容吗?logdb结构类似于profile-authid-username,msgnumber。。。可能是因为authid?你能发布你在控制台中看到的json吗?谢谢我更改了它,但仍然无法在页面上显示(html)如果你将profileData的类型更改为Observable而不是AngularFireList,会有帮助吗?谢谢我更改了它,但仍然无法在页面上显示(html)如果您将profileData的类型更改为Observable而不是AngularFireList,会有帮助吗?