Angular ionic 6-用于不显示数据firebase实时数据库

Angular ionic 6-用于不显示数据firebase实时数据库,angular,firebase,ionic-framework,ngfor,Angular,Firebase,Ionic Framework,Ngfor,我尝试了各种方法来显示数据库(Firebase realtime数据库)中的数据。有以下配置规则: { “规则”:{ “.read”:“true”, .write:“正确” } } 数据来自数据库(Firebase实时数据库),但它不会在UI上显示任何记录。当我打印数据的console.log时,它是正确的。下面是我使用过的代码段,我对爱奥尼亚的开发完全陌生,所以如果我犯了任何错误,请指出 home.page.html 空白 空白 {{user.first{u name} 主页.ts 从'

我尝试了各种方法来显示数据库(Firebase realtime数据库)中的数据。有以下配置规则:

{
“规则”:{
“.read”:“true”,
.write:“正确”
}
}
数据来自数据库(Firebase实时数据库),但它不会在UI上显示任何记录。当我打印数据的
console.log
时,它是正确的。下面是我使用过的代码段,我对爱奥尼亚的开发完全陌生,所以如果我犯了任何错误,请指出

home.page.html


空白
空白
{{user.first{u name}
主页.ts

从'@angular/common/http'导入{HttpClient};
从“@angular/core”导入{Component,OnInit};
@组成部分({
选择器:“应用程序主页”,
templateUrl:'home.page.html',
样式URL:['home.page.scss'],
})
导出类主页{
用户:任意[]=[];
构造函数(私有http:HttpClient){}
ngOnInit(){
这是http.get(“https://food-ea070-default-rtdb.firebaseio.com/users.json)订阅(数据=>{
this.users=JSON.parse(JSON.stringify(data));
控制台日志(“数据”,数据);
});
}
}
数据正确来自
控制台.log中的数据库

{“0”:
{“阿凡达”:https://firebasestorage.googleapis.com/v0/b/food-ea070.appspot.com/o/polloalabrasa.jpg?alt=media&token=5b226d30-2eb2-417d-9c94-c1b25e9890fa,“电子邮件”:“迈克尔。lawson@reqres.in,“名字”:“迈克尔”,“身份证”:7,“姓氏”:“劳森”},
“-MUsoe5L3d3F1-E-nmC_2;”:
{“阿凡达”:https://reqres.in/img/faces/1-image.jpg“,”电子邮件“:”乔治。bluth@reqres.in“,”姓“:”乔治“,”身份证“:”1,“姓“:”布鲁斯“},
“-MUsoqU00M9v0QR772aK”:
{“阿凡达”:https://reqres.in/img/faces/2-image.jpg“,”电子邮件“:”珍妮特。weaver@reqres.in,“名字”:“珍妮特”,“身份证”:2,“姓氏”:“韦弗”},
“-MUsotIie6a5cU62E_UK”:
{“阿凡达”:https://reqres.in/img/faces/3-image.jpg“,”电子邮件“:”艾玛。wong@reqres.in“,”姓“:”爱玛“,”身份证“:”3,“姓“:”王“},
“-MUsp1tWC4ABqPvDLgs9”:
{“阿凡达”:https://reqres.in/img/faces/5-image.jpg,“电子邮件”:“查尔斯。morris@reqres.in,“姓”:“查尔斯”,“身份证”:5,“姓”:“莫里斯”},
“-MUsp4Qm0Cyd9sfgcZ7m”:
{“阿凡达”:https://reqres.in/img/faces/6-image.jpg“,”电子邮件“:”特雷西。ramos@reqres.in,“名字”:“特雷西”,“id”:6,“姓氏”:“拉莫斯”}
}
您的“数据”是JSON的对象,但不是数组

{
  "0": {
    "avatar": "https://firebasestorage.googleapis.com/v0/b/food-ea070.appspot.com/o/polloalabrasa.jpg?alt=media&token=5b226d30-2eb2-417d-9c94-c1b25e9890fa",
    "email": "michael.lawson@reqres.in",
    "first_name": "Michael",
    "id": 7,
    "last_name": "Lawson"
  },
  ...
}
<ion-item *ngFor="let user of users">
在模板中,用户被视为一个数组

{
  "0": {
    "avatar": "https://firebasestorage.googleapis.com/v0/b/food-ea070.appspot.com/o/polloalabrasa.jpg?alt=media&token=5b226d30-2eb2-417d-9c94-c1b25e9890fa",
    "email": "michael.lawson@reqres.in",
    "first_name": "Michael",
    "id": 7,
    "last_name": "Lawson"
  },
  ...
}
<ion-item *ngFor="let user of users">

您的JSON无效