0

Suppose I requested for data in angularfire2 like this:

var ref = new Firebase("firebase url");

Now how can I apply rxjs operator like map operator to the data coming

blackHawk
  • 6,047
  • 13
  • 57
  • 100

1 Answers1

0

I don't think you are looking at angularfire2 there - that's v1 code...

You can use the rxjs operators in angularfire2 - the data is returned as an Observable (FirebaseListObservable or FirebaseObjectObservable) - so you can import and apply any of the rxjs operators to those...

In general, you just assign the data to a variable and have the template handle it with the async pipe

@Component({
  selector: 'app',
  templateUrl: `
  <ul>
    <li *ngFor="let item of items | async">
      {{ item.name }}
    </li>
  </ul>
  `,
})
class AppComponent {
  items: FirebaseListObservable<any>;
  constructor(af: AngularFire) {
    this.items = af.database.list('/items');
  }
}

But you can use the rxjs operators (be sure to import what you want)

this.af.database.list('/items')
.map(value => {
    console.log(value);
    return value; // do something with value etc.
})
.subscribe(data => console.log(data));

More here: AngularFire2