我已经列出了一些项目,需要按优先级将它们整理成列表。agularjs自定义订单和限制
items = [
{'type': 2, 'priority': 1, 'name': 'one'},
{'type': 1, 'priority': 2, 'name': 'two'},
{'type': 1, 'priority': 3, 'name': 'three'},
{'type': 1, 'priority': 4, 'name': 'four'},
{'type': 1, 'priority': 5, 'name': 'five'},
{'type': 2, 'priority': 6, 'name': 'six'},
]
而我需要按ng-repeat
按优先级排序,并按类型分开。在一个列表type
值的最大总和应为4。所以输出应该像(由name
)
['one', 'two', 'three', 'four']
['five', 'six']
什么是这里的问题是什么呢?还是你希望我们为你做这项工作? –
我试过写我自己的逻辑,但没有奏效。完全不知道从什么开始。而不是要求为我做所有事情,只要指出我的方式。 – gordon33
在控制器中安排你的数据,使用像lodash这样的东西来帮助你处理你的数据https://lodash.com/ –