【发布时间】:2018-03-08 05:26:09
【问题描述】:
我有一个ng-repeat,在下拉列表中有以下值。
Up to 6 months
From 13 to 24 months
Higher than 24 months
From 6 to 12 months
我需要像下面这样对值进行排序
//following is the expected output
// Up to 6 months
//From 6 to 12 months
//From 13 to 24 months
//Higher than 24 months
$scope.items = [{name: 'Up to 6 months', id: 30 },{ name: 'From 13 to 24 months', id: 27 },{ name: 'Higher than 24 months', id: 50 },{ name: 'From 6 to 12 months', id: 50 }];
【问题讨论】:
-
你不能在每个项目中放置一个排序顺序,然后按那个排序顺序排序吗?
-
我需要根据什么对每个项目进行排序
-
基于名称值在逗号分隔字符串中的位置“最长 6 个月,从 6 到 12 个月,从 13 到 24 个月,高于 24 个月”。我希望这不是它在数据库中的存储方式 - 您将如何处理将“超过 24 个月”更改为“超过两年”的请求?
标签: javascript html angularjs angularjs-orderby