我有我想要一個特定的方式進行排序的對象數組:角NG重複多排序
[
{
name: 'Blackcurrant',
created_at: '3/2/2014'
},{
name: 'Bilberry',
created_at: '1/2/2013'
},{
name: 'Apple',
created_at: '11/5/2012'
},{
name: 'Boysenberry',
created_at: '1/1/2014'
},{
name: 'Coconut',
created_at: '3/4/2011'
},{
name: 'Breadfruit',
created_at: '6/6/2013'
},{
name: 'Currant',
created_at: '2/8/2014'
},{
name: 'Avocado',
created_at: '5/13/2014'
},{
name: 'Banana',
created_at: '7/16/2014'
},{
name: 'Blueberry',
created_at: '1/18/2010'
},{
name: 'Apricot',
created_at: '9/17/2014'
},{
name: 'Date',
created_at: '2/22/2012'
},{
name: 'Damson',
created_at: '10/10/2014'
},{
name: 'Cantaloupe',
created_at: '8/13/2014'
},{
name: 'Cranberry',
created_at: '4/25/2011'
},{
name: 'Cucumber',
created_at: '7/6/2014'
},{
name: 'Blackberry',
created_at: '2/10/2014'
},{
name: 'Cloudberry',
created_at: '1/23/2014'
},{
name: 'Cherry',
created_at: '7/11/2013'
},{
name: 'Cherimoya',
created_at: '11/19/2014'
}
]
我需要能夠有它設置,以至於當我做一個ng-repeat,Coconut,Banana,Cantaloupe和Cherry在開始時按順序顯示,然後按照created_at日期排序。有可能使用orderBy和過濾器的組合嗎?
推JSON值到你希望的順序數組。然後在視圖中引用數組而不是JSON。 –
你需要order by你的自定義函數 –
@TheHeadRush:我會做那樣的事情,但我需要原始的範圍,因爲它不斷更新,它只是更多的工作,以不斷更新新的JSON每次它的變化。 – m0ngr31