【发布时间】:2018-12-30 07:31:24
【问题描述】:
我正在使用 Angular6 并尝试在此过滤器函数中获取文档内容。我的代码 sn-p 的最后一行给了我错误“无类型函数调用可能不接受类型参数”。不知道为什么我会收到这个错误...也许它不能在过滤器函数中使用...?
构造函数:
constructor(private afs : AngularFirestore, private authService : AuthService) {
//Get user collection on initialise
this.userCollection = this.afs.collection('users');
}
过滤:
this.userCollection = this.afs.collection<User>('users', ref => {
console.log(ref);
return ref
})
this.usersOnSearch = this.userCollection.valueChanges();
this.usersOnSearch.flatMap(user => {
return user.filter(function(value) {
let subjectTrue : boolean = false;
let levelTrue : boolean = false;
let docID : string = value.user_subjects.id;
let userLevelPriceDocument : AngularFirestoreDocument<UserSubjects>;
userLevelPriceDocument = this.afs.doc<UserSubjects>(`user_subjects/${docID}`);
})
});
【问题讨论】:
-
如果你删除
,你有错误吗?我们也可以有你的构造函数吗?还有你的组件变量 -
如果我删除
我不再收到错误消息。其他信息已更新。 -
您似乎根本没有在 filter() 函数中返回任何内容 - 您是否应该返回 true/false 来指示是否应将给定用户包含在结果中?
标签: angular rxjs observable google-cloud-firestore angular6