【问题标题】:Firebase orderBy descending [duplicate]Firebase order按降序[重复]
【发布时间】:2015-12-08 07:29:38
【问题描述】:

我在 Firebase 中有一个数组,如下所示:

var ref = new Firebase(url);
ref.orderByChild("date").on("child_added", function(obj) {
    console.log(obj.val());
});

但我需要按降序排列。如何使用 Firebase 做到这一点?

谢谢!

【问题讨论】:

标签: javascript jquery angularjs firebase


【解决方案1】:

由于您添加了 AngularJS 标签,我假设您在项目中使用 Angular。在这种情况下,使用 AngularFire (http://angularfire.com) 会让你的生活变得更加轻松。

使用 AngularFire 后,您可以使用 $firebaseArray 服务从数据库中获取您的数组,并像对任何其他数组一样对其进行排序。

$firebaseArray 文档可在此处找到:https://www.firebase.com/docs/web/libraries/angular/guide/synchronized-arrays.html

【讨论】:

    猜你喜欢
    • 2023-03-03
    • 2020-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-06
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    相关资源
    最近更新 更多