抱歉,如果我的术语有误。
我正在尝试列出一个电影列表,其中的日期显示在一个可以按任一属性排序的列表中。当使用本地 JSON 文件和 $http
时,我可以执行此操作,但一旦我转向异步实现,绑定(bind)就会失败。
这是一个示例:http://jsbin.com/nelora/3/edit
任何帮助将不胜感激。
最佳答案
The orderByPriority filter is provided by AngularFire to convert an object returned by $firebase into an array. The objects in the array are ordered by priority (as defined in Firebase). Additionally, each object in the array will have a $id property defined on it, which will correspond to the key name for that object.
这里的关键是它将其转换为数组 - 然后您可以通过自己的过滤器对其进行排序,因为 Firebase 返回对象,而不是数组。
<li ng-repeat="movie in movies | orderByPriority | orderBy:orderProp">
{{movie.year}}—{{movie.title}}
</li>
https://www.firebase.com/docs/angular/reference.html#orderbypriority
关于javascript - angularJS 将异步数据绑定(bind)到 ng-repeat orderBy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24764564/