在正确排序的同时从 firebase 检索数据

Retrieving data from firebase while sorting it correctly

我的 firebase 数据库中有这个结构

"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
        }
      }
    }
  }

我想在我的应用中实现的是显示这样的列表

> Januari
>   - 45 (=price)
> 
> Februari
>   - 90 ()
>   - 240

问题是我能够显示月份,但由于 firebase 创建的唯一 ID,我无法到达 children。

这是 object 我从 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
}

我该如何处理?

您要使用 ng-repeat 吗?这样的东西对你有用吗:

<div ng-repeat="(name, month) in months">
    {{ name }}
    <div ng-repeat="entry in month">
        {{ entry.price }}
    </div>
</div>

其中月份是 database.ref().child('metaData').child('2017');

的结果