【发布时间】:2020-10-24 10:52:31
【问题描述】:
我使用了来自 @angular/fire/database 的 AngularFireList 从 firestore 获取数据,而 firestore 包含数据但我无法从中获取任何数据。
import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireList, AngularFireObject } from '@angular/fire/database';
import { Customer } from '../shared/customer.model';
@Injectable({
providedIn: 'root'
})
export class CustomerService {
customersRef: AngularFireList<any>; // Reference to Student data list, its an Observable
customerRef: AngularFireObject<any>; // Reference to Student object, its an Observable too
// Inject AngularFireDatabase Dependency in Constructor
constructor(private db: AngularFireDatabase) { }
getCustomersList() {
this.customersRef = this.db.list('customers');
return this.customersRef;
}
getCustomer(id: string) {
this.customerRef = this.db.object('customers/' + id);
return this.customerRef;
}}
【问题讨论】:
标签: angular typescript google-cloud-firestore