我已經列出了一些項目,需要按優先級將它們整理成列表。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/ –