angularjs ng-repeat ordering string arrays in numerical order

你离开我真会死。 提交于 2019-11-30 16:25:56

I guess your ids are strings. A simple solution would be use a no. operation inside order by. So instead ofr orderBy:'id' just use orderBy:'id*1' this will consider the id as no. and sort it according to the numerical order.

This is all you need - <div ng-repeat="fiche in fiches | orderBy:'id*1'">{{fiche.id}}</div>

Demo: http://plnkr.co/edit/MSrPTZQP49F7Nzwhv6ef?p=preview

Ideally it should Print the correct list in ng-repeat using order-by. I am adding a fiddle example with the same.Its a basic example. Hope it helps

>  http://jsfiddle.net/L45cE/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!