在正确排序的情况下从Firebase中检索数据 [英] Retrieving data from firebase while sorting it correctly
本文介绍了在正确排序的情况下从Firebase中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的firebase数据库中有这样的结构
I have this structure in my firebase database
"metadata" : {
"2017" : {
"Februari" : {
"-Kc3BF0V1iLgtnI65LuR" : {
"date" : "2017-02-03T13:36:38.311Z",
"price" : 90
},
"-Kc3BF0V1xxfrtnI65OlS" : {
"date" : "2017-02-03T13:36:38.311Z",
"price" : 90
}
},
"Januari" : {
"-Kc3E5bpxpo3RpSHH3fn" : {
"date" : "2017-01-11T13:50:12.264Z",
"price" : 45
}
}
}
}
我试图在我的应用程序中实现的是显示一个像这样的列表
What I am trying to achieve in my app is to show a list like this
> Januari
> - 45 (=price)
>
> Februari
> - 90 ()
> - 240
事情是我可以显示月份,但我无法联系到孩子因为Firebase创建的唯一ID。
The thing is I am able to show the months, but I can't reach the children because of the unique ID created by firebase.
这是我从firebase返回的对象
This is the object I am getting back from firebase
e{
$$conf: Object
$id: "2017"
$priority: null
Februari: Object
-Kc3BF0V1iLgtnI65LuR: Object
date: "2017-02-03T13:36:38.311Z"
price: 90
Januari: Object
-Kc3E5bpxpo3RpSHH3fn: Object
date: "2017-01-11T13:50:12.264Z"
price: 45
}
我会如何处理这个问题? p>
How would I approach this?
推荐答案
您是否正在尝试使用ng-repeat?这样的工作会对你有用:
Are you trying to use an ng-repeat? Would something like this work for you:
<div ng-repeat="(name, month) in months">
{{ name }}
<div ng-repeat="entry in month">
{{ entry.price }}
</div>
</div>
其中months是 database.ref() metaData')。child('2017');
这篇关于在正确排序的情况下从Firebase中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文