纯 Firebase JavaScript API 的 orderby 对象过滤器 [英] A orderby object filter for a pure Firebase JavaScript API

查看:24
本文介绍了纯 Firebase JavaScript API 的 orderby 对象过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 angularFire 在与纯 Firebase JavaScript API 结合使用时总是让我感到困惑.

假设我不知道如何在 angularFire 中调用 Firebase datasapshot API ss.name()ss.hasChild()、ss.forEach() 等.

所以我决定单独使用 Firebase JavaScript API,因为我意识到它已经具有与 AngularJS 的双向数据绑定(显式),而无需使用 angularFire.

没有 ngFire 的演示

但是我遇到了 ng-repeat 的问题.返回的数据是一个对象,所以我无法排序.然后我找到了这个orderByObject过滤器,但是一旦转换成数组,我就会丢失对象键.

Firebase 团队能否帮助我改进此 orderByObject 过滤器以支持对象键?

解决方案

您可以使用 orderByPriorityfirebase 对象转换为数组,然后应用普通过滤器和 orderBy.

 

<span>{{ customer.$id }} </span>

I found angularFire is always confusing me when used in conjunction with the pure Firebase JavaScript API.

Let's say I have no idea how to call the Firebase datasapshot API ss.name(), ss.hasChild(), ss.forEach() etc in angularFire.

So I decide to use the Firebase JavaScript API alone because I realized it already has two-way data binding (explicit) with AngularJS without using angularFire.

Demo without ngFire

But I got a problem with the ng-repeat. The returned data is an object so I cannot sort. Then I found this orderByObject filter, but once converted to array, I would lose the object key.

Can the Firebase team help me to improve this orderByObject filter to support the object key?

解决方案

You can use orderByPriority to convert firebase objects into array and then apply normal filter and orderBy.

 <div ng-repeat="customer in customers | orderByPriority | filter:searchText">
     <span>{{ customer.$id }} </span>
 </div>

这篇关于纯 Firebase JavaScript API 的 orderby 对象过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆