Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase Can';t显示阵列到离子_Firebase_Ionic Framework - Fatal编程技术网

Firebase Can';t显示阵列到离子

Firebase Can';t显示阵列到离子,firebase,ionic-framework,Firebase,Ionic Framework,我无法使用NgFor将阵列显示到离子视图 this.dbFire.database.ref('found').orderByChild('author_email').equalTo(this.email).once('value') .then(snapshot => snapshot.val()) .then((data) => { // push data this.

我无法使用NgFor将阵列显示到离子视图

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);
            });

View:
    <ion-col  *ngFor="let posts of getUserPosts">
        <p>{{posts.post_name}}</p>
        <p></p>
    </ion-col>
this.dbFire.database.ref('found').orderByChild('author_email').equalTo(this.email).once('value'))
.then(snapshot=>snapshot.val())
。然后((数据)=>{
//推送数据
this.getUserPosts.push(数据);
log(this.getUserPosts);
});
视图:
{{posts.post_name}


根据
getUserPosts
的结构,您应该执行以下操作: 添加新的类成员
postids
作为字符串数组。代码修改如下:

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);
    this.postids =  Object.keys(this.getUserPosts[0]);
    console.log(this.postids);
            });
视图:


{{getUserPosts[0][postid].post_name}


请向我们展示
console.log(this.getUserPosts)的输出。
请参阅post中的console.log锚定。有console.log(this.getUserPosts)的输出新错误:错误:未捕获(承诺中):类型错误:无法读取未定义类型的属性“键”错误:无法读取未定义类型的属性“键”谢谢!请再试一次。。。之前我键入了Object.keys而不是Object.keys好的,然后创建一个名为postids的数组数据类型的datamember并使用它。。。我将相应地更新答案。我们需要将密钥作为Object存储在单独的数组中。密钥在ngFor中不起作用。Angular假设这里的对象是类的datamember,但由于我们没有任何名为Object的datamember,所以会出现这样的错误。请尝试答案中的更新代码。有效!非常感谢。
<ion-col  *ngFor="let postid of postids">
    <p>{{ getUserPosts[0][postid].post_name}}</p>
    <p></p>
</ion-col>