我在 Angular Web 应用程序中使用 AngularFire2。由于 Firebase 的查询限制,我无法形成一个准确地提供我需要的数据的查询(至少在不对我的架构进行重大更改的情况下不会)。
所以我想在javascript(打字稿)中应用一个额外的客户端过滤条件。我该怎么做呢?我可以以某种方式向可观察对象添加过滤器功能吗?下面是一个片段,说明了我在做什么。
在组件的 HTML 模板中,我在下面有类似的内容。html 片段中的“jobs”变量是 FirebaseListObservable。
<tr *ngFor="let job of jobs | async">
.. fill in the table rows
组件代码如下所示:
// in the member declaration of the class
jobs : FirebaseListObservable<Job[]>;
...
// Notice in ngOnInit(), I'm filtering the jobs list using the the
// Firebase criteria. But I want to filter on an additional field.
// Firebase allows only single field criteria, so I'm looking for
// a way to apply an additional client-side filter to jobs to eliminate
// some additional records.
ngOnInit(){
this.jobs = this.af.database.list("/jobs/", {query: {orderByChild : "companyKey", equalTo:someKey}})
}
有没有办法在“this.jobs”上应用过滤器组件,以便我可以应用本地(客户端)过滤器?