项相反的顺序从数据库中NG-重复拉 [英] Reverse order of items pulled from database in ng-repeat

查看:126
本文介绍了项相反的顺序从数据库中NG-重复拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MongoDB数据库为用户在某些地点拍摄照片Instagram上所更新照片阵列。
我把每个新照片,以这个照片阵列信息,因此最新的照片是在数组的末尾。这是我的问题就出现了。

I have a 'photos' array in a MongoDB database that is updated as users take photos on Instagram at certain locations. I push information about each new photo to this 'photos' array, so the most recent photo is on the end of the array. This is where my issue arises.

我用NG-重复在我看来,以显示这些照片。最明显的问题是,最近的照片在页面的结尾结束,而不是开始。

I use ng-repeat to display these photos in my view. The obvious problem is that the most recent photo ends up at the end of the page rather than the beginning.

什么是颠倒顺序NG重复显示在最简单的方法?我一直没能找到一个内置的过滤器,这样做了。

What is the easiest way to reverse the order ng-repeat displays in? I have not been able to find a built-in filter that does this.

推荐答案

反向的数组你得到的数据之后。

Reverse the array after you get the data.

data.reverse();

HTML

<element ng-repeat="data" ...

您也可以编写一个过滤器来做到这一点。有没有内置过滤器反向AFAIK。

You can also write a filter to do that. There is no built-in filter for reverse AFAIK.

这篇关于项相反的顺序从数据库中NG-重复拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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