我正在从Firestore数据库下载数据。之后,我想遍历我的Observable并获得一个特定值。
为此,我尝试了以下操作:
interface Note{
imageUrl: string;
title: string;
body: string;
titledesc: string;
imgalt: string;
imgdesc: string;
imgtitle: string;
authorId: string;
}
这是我的变量:
notesCollection: AngularFirestoreCollection<Note>;
notes: Observable<Note[]>;
这是我的方法:
getAuthorData = function(blog: string){
this.notesCollection = this.afs.collection('/Blogs', ref =>{
return ref.where('title','==', blog)
}).valueChanges()
this.notesCollection.subscribe( data => {
console.log(data.authorId)
});
}
日志始终显示未定义