我有類似如下的數組:過濾器由物業兒童陣列使用underscore.js
var result=[{"id": 1, "details": [{"ah": 1.0, "dId": 11},{"ah": 2.0, "dId": 11}, {"ah": 2.0, "dId": 12}]}, {"id": 2, "details": [{"ah": 1.0, "dId": 11},{"ah": 2.0, "dId": 11}]}]
現在我想通過編號進行篩選,它並沒有的屬性使用underscore.js,例如。給我所有關於id = 1和dId = 11的細節,並且做出ah-性質的總和。所以例如。濾波ID = 1和DID = 11應該返回3.
我想是這樣的:_.where(result, {id: 1, details.dId:11})
但我無法得到它的工作。
我創建了一個小提琴: http://jsfiddle.net/j9Htk/
任何幫助表示讚賞
感謝
托馬斯