这是我的代码。
export class ErrandsComponent implements OnInit {
private itemsCollection: AngularFirestoreCollection<Item>;
items: Observable<Item[]>;
constructor(private db: AngularFirestore) {
this.itemsCollection = db.collection<Item>('errands');
this.items = this.itemsCollection.valueChanges();
}
ngOnInit(){
var errands = Array.of(this.items);
console.log(this.items)
};
}
我想把Observable的集合(Observable,现在只有一个)变成一个Array的过程是因为我得到了一个错误,说明:
NgFor只支持绑定Iterables,如Arrays。
我的目标是使用我的集合中的数据,并在模板中做一个ngFor,以显示出 list
和 location
.