错误:
[ts] Cannot invoke an expression whose type lacks a call signature. Type 'DatabaseSnapshot<any>' has no compatible call signatures.
(parameter) item: AngularFireAction<DatabaseSnapshot<any>>
文件消费服务:
**Error is at ...Item.payLoad().val()**
constructor(private service: EmployeeService) { }
ngOnInit() {
this.service.getEmployees().subscribe(list => {
let array = list.map(item => {
return { $key: item.key, **...item.payload().val()** }
})
});
}
**Method-II**
getEmployees() {
this.employeeList = this.db.list('employees');
return this.employeeList.snapshotChanges();
}
答案 0 :(得分:0)
item.payload
是一个属性,而不是一个函数,如您所见,是否在您的IDE中跳至its definition:
export interface Action<T> {
type: ListenEvent;
payload: T; // <---
};
export interface AngularFireAction<T> extends Action<T> {
prevKey: string | null | undefined;
key: string | null;
}
因此,您应使用item.payload
而不要调用它:删除item.payload
之后的括号。