-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
I have a list of employees. Every employee has a name and and active property, e.g.
{
name: "Dirk Postma",
active: true
}
In my view I'd like to be able to filter by active flag, for example:
this.filteredItems = af.database.list('employees', {
query: {
orderByChild: 'active',
equalTo: this.querySubject
}
});
toggleActiveFilter() {
this.showActive = !this.showActive;
this.querySubject.next(this.showActive);
}
This works, great stuff!
Now one step further: I'd like to be able to show either active employees or ALL employees (both active and inactive). I would like to have something like this:
this.filteredItems = af.database.list('employees', this.querySubject });
toggleActiveFilter() {
this.showActive = !this.showActive;
if (this.showActive) {
// Show active employees only
this.querySubject.next({
query: {
orderByChild: 'active',
equalTo: true
}
});
} else {
// show all employees
this.querySubject.next(null);
}
}
Basically: make the second parameter itself an Observable in stead of just the inner values of e.g. equalTo.
Is this an idea?
agu-z and drew-moore