【发布时间】:2017-01-31 19:23:48
【问题描述】:
我可以通过我的问题querying subset from angularfire2 实现一些过滤行为。现在我想使用 ngFor 将这些值显示为 Angular 中的列表。在我的 ts 文件中,我有:
export class OtherAnimals{
public animalList: Observable<{}>;
constructor(public af: AngularFire) {
this.animalList = Observable.combineLatest(
this.af.database.object('/set1/'),
this.af.database.object('/set2/'),
// Use the operator's project function to emit an
// object containing the required values.
(set1, set2) => {
let result = {};
Object.keys(set1).forEach((key) => {
if (!set2[key]) {
result[key] = this.af.database.object('/allanimals/' + key);
}
});
return result;
}
);
}
}
在我的.html 文件中,我有:
<ul>
<li *ngFor="let item of animalList | async">{{item.name}}</li>
</ul>
【问题讨论】:
-
看起来唯一缺少的是大括号:
...">{{ item.name }}</li> -
这是一个错字@cartant,刚刚在问题中修正
标签: firebase firebase-realtime-database angularfire2