*ngFor is used yet html shows object,object

Hi guys, need help why doesn’t my html show the data instead showing of [object,object]. I have used ngFor to load the array.

This is my html code,

        <ion-item *ngFor="let x of allItemRef$ | async;">

this is ts code

allItemRef$: FirebaseListObservable<allItem[]>

  constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController, public database: AngularFireDatabase) {

   this.allItemRef$ = this.database.list('list');

I looked up other tutorial, they uses ngFor it works what have I done wrong?



        <ion-item *ngFor="let x of allItemRef.anArray | async;">

Or if you have an array inside an array

        <ion-item *ngFor="let x of allItemRef$ | async;">
            <span *ngFor="let y of x.anArray">

Thankyou, for the reply and help. Nope both of the code don’t work.

  1. The code stated that, “Identifier ‘allItemRef’ is not defined. The component declaration, template variable declarations, and element references do not contain such a member”.

So I added the dollar sign it became

“Identifier ‘anArray’ is not defined. ‘FirebaseListObservable’ does not contain such a member”

For the 2) I do feel that my code is array in array. However, nothing appear.

Thankyou once again.

What is the output when you console.log(allItemRef) in your ts-file?

the output is [object Object].

if I do a for loop same output, [object Object].

for ( let i in this.allItemRef$){

If I put into

it return me error message:
ERROR TypeError: Converting circular structure to JSON
at JSON.stringify ()

the output is [object Object].

Can you expand the [object Object] in the terminal?

I can’t seems to expend it.


Anyone could help I have been struggle for past few days thanks.

just ngFor change to ngIf

Can you teach me how to use it? Because I am not able to apply it into using for loop. Infact it looks weird.

You can try like this.

html code

<div *ngFor="let item of users">

    <h2>Name : {{item.Name}}</h2>

ts file

export class HomePage {
users: any;
  constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http) {


 ionViewDidLoad() {
   var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

      let dataTemp = res.json(); //dataTemp is the json object you showed me
      this.users = dataTemp.GetAllUsers; //contains a [] object with all yours users