Skary Skary - 2 years ago 194
TypeScript Question

AngularFire2 DB call is not executed

i am trying to filter a DB List from Angularfire2 in Typescript to get a specific Record.

let existingAppointment = => {
let filtered = values.filter(filter => filter.Date === date);
return filtered;

The Problem is : The map Method is not Executed . I can do what i want, its not executing, only when i add the subscribe function in the End.
In all Tutorials ony the Map Method is called.

I am using the Version [email protected]^2.0.0-beta.2

What am i doing wrong ?

Answer Source

I think you want something like this instead

this.items = af.database.list('this.appointmentDbRoute', { preserveSnapshot: true });
  .subscribe(snapshots => {
    snapshots.forEach(snapshot => {

from documentation here:

you are trying to call map on a FirebaseObservable since your call

returns a FirebaseObservable you need to subscribe to get results and then perform the filtering

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download