嗨,我是Handlebarsjs的新手。如何在Handlebarsjs中按字母順序顯示姓名underscorejs
我有姓名,電子郵件,電話,聯繫人等的集合如下
[
{
"name": "Bob Wolmer",
"email": "[email protected]",
"phone": "(535) 235-1234",
"address": "301 Cobblestone Wy., Berdrock 00000",
"contactId": "1121",
"labels": {}
},
{
"name": "Wilma Erra",
"email": "[email protected]",
"phone": "(535) 235-3659",
"address": "301 Cobblestone Wy., Berdrock 70777",
"contactId": "1122",
"labels": {}
},
{
"name": "Brad",
"email": "[email protected]",
"phone": "(535) 235-3546",
"address": "301 Cobblestone Wy., Redrock 70777",
"contactId": "1123",
"labels": [{"name": "Friends"},{"name": "Family"}]
},
{
"name": "",
"email": "[email protected]",
"phone": "(535) 235-3657",
"address": "301 Cobblestone Wy., Dedrock 70777",
"contactId": "1124",
"labels": [{"name": "Friends"}]
}
]
我想如下
B
Bob
Brad
W
Wilma Erra
任何一個可以建議我怎麼顯示名字做到這一點。
由於提前
感謝您的時間@dcarson,有沒有辦法讓這個功能可以對集合執行對象。 雖然sortBy沒有工作,但我已經使用比較排序的集合,如下面 'this.collection.comparator =功能(項目){ \t回報[item.get(「郵件」),item.get (「名稱」)]; \t}; \t \t this.collection.sort();' – Kris
你的意思是在Backbone集合上執行這個功能嗎? – dcarson