错误显示从Firebase到离子的数据

时间:2018-08-15 10:21:13

标签: javascript firebase ionic-framework

我想显示该console.log中的数据,但出现错误。

enter image description here

  

错误是:错误:找不到类型为'object'的其他支持对象'[object Object]'。 NgFor仅支持绑定到数组等Iterable。

这是代码的一部分:

this.dbFire.database.ref('found').orderByChild('author_email')
            .equalTo(this.email)
            .once('value')
            .then(snapshot => snapshot.val())
            .then((data) => {
                this.getUserPosts = data;

                console.log(this.getUserPosts);
            });

谢谢!

1 个答案:

答案 0 :(得分:0)

// declare variable as empty array
getUserPosts: any[] = [];

this.dbFire.database.ref('found').orderByChild('author_email').equalTo(this.email).once('value')
    .then(snapshot => snapshot.val())
    .then((data) => {
        // push data
        this.getUserPosts.push(data);
        console.log(this.getUserPosts);
    });

<li * ngFor="let user of getUserPosts" >
    {{ user.author_email}}
</li>