Ionic 2 and Angularfire 2 FirebaseListObservable


#1

Hi, This is docs on Angularfire 2:

**Retrieve data**

To get the list in realtime, create a list binding as a property of your component or service. Then in your template, you can use the async pipe to unwrap the binding.

import {Component} from 'angular2/core';
import {AngularFire, FirebaseListObservable} from 'angularfire2';

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


 ==> this.item = af.database.list('/items');

How do foreach this.item, i want loop and code something on this.item

foreach(var key in this.item) {
//code
}

Not working, :frowning:


#2

Can you give a bit more of feedback?

What is happening?


#3

this.item = af.database.list(’/item’);

here, this.item is type observable

I don’t known how use ‘foreach’.

Ex: foreach(var key in this.item){
}