我在任何从firestore接收的类型的observable上面临切片操作错误 . 我正在尝试使用firestore数据自动完成角度材料 .
export class HomeComponent implements OnInit {
customerCtrl: FormControl;
filteredCustomer: Observable<any[]>;
customers_coll: AngularFirestoreCollection<any>;
customers: Observable<any[]>;
constructor(private afs: AngularFirestore,private _data: DataService) {
console.log("home");
this.customerCtrl = new FormControl();
this.customers_coll =
this.afs.collection('USERS').doc(this._data.phone).collection("CUSTOMERS");
this.customers = this.customers_coll.valueChanges();
}
ngOnInit() {
this.filteredCustomer = this.customerCtrl.valueChanges
.pipe(
startWith(''),
map(customer => customer ? this.filterCustomer(customer) :
this.customers.slice())
);
}
filterCustomer(name: string) {
return this.customers.filter(customer =>
customer.NAME.toLowerCase().indexOf(NAME.toLowerCase()) === 0);
}
}