我想显示该console.log中的数据,但出现错误。
错误是:错误:找不到类型为'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);
});
谢谢!
答案 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>