我上传列表如下:
export interface Data {
name: string;
address: string;
address2: string;
pscode: string;
ccode: string;
name2: string;
}
constructor(private afs: AngularFirestore){
this.notesCollection = this.afs.collection(`imones`, (ref) => ref.orderBy('time', 'desc').limit(5));
}
notesCollection: AngularFirestoreCollection<Data>;
//creating item in list (imones)
createItem(){
this.notesCollection.add(this.busines);
}
现在的问题是如何从中获取所有列表项?
这是我的尝试:
constructor(private afs: AngularFirestore){
this.items = this.notesCollection.valueChanges();
}
items: Observable<Data[]>;
HTML格式:
<p *ngFor="let item of items">{{item.name}}</p>
类型为“object”。NgFor只支持绑定到Iterables,例如
数组。
再次出错: