排序依据不是字典语法工作纳克重复 [英] Orderby not working with dict syntax on ng-repeat

查看:146
本文介绍了排序依据不是字典语法工作纳克重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用NG重复使用字典风格的语法并应用以键值。

I am trying to use ng-repeat with a dictionary style syntax and apply an order to the key value.

(键,值)的东西|排序依据:钥匙

这似乎预期排序依据是不工作

It seems OrderBy isn't working as expected

下面举例
http://jsfiddle.net/mhXuW/

推荐答案

参数为排序依据,必须在对象数组属性名相匹配。

The parameters to orderBy must match property names in an array of objects.

您的数据需要看起来像这样:

Your data needs to look something like this:

$scope.list2 = [ { id:"2013-01-08T00:00:00", name:'Joe'},
                 { id:"2013-01-09T00:00:00", name:'Sue'}];

然后像这样的过滤器将工作:

Then a filter like this will work:

<div ng-repeat="item in list2 | orderBy:'id':true">

小提琴

需要注意的是排序依据的作品,整个阵列(的东西在你的样品code以上),并返回一个排序的数组。排序依据不知道任何有关

Note that orderBy works on the entire array (something in your sample code above) and it returns a sorted array. orderBy doesn't know anything about key and value.

这篇关于排序依据不是字典语法工作纳克重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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