我使用MongoDB的,我想在我的角度應用程序使用Underscore.js。 我有一個模型「電子郵件」與領域:「主題」,「身體」和「身份證」。下劃線的findWhere和MongoDB對象
此電子郵件對象看起來像這樣在瀏覽器控制檯:
$$hashKey
"005"
_id
Object { $oid="5478774a6a61734d8a000000"}
body
"Here is the sample conte...le ble ble. Nice email."
subject
"This is first template"
這是角控制器代碼:
$scope.viewEmail = function(emailId) {
var email = _.findWhere(emailData.data.emails, { _id: emailId });
console.log(email);
};
所以,我只是想找到與特定id
電子郵件 - 我想要得到的id
被保存在一個局部變量emailId
。
我應該做這樣的事情:_id.$oid: emailId
但它會導致一個語法錯誤在JavaScript控制檯:「丟失:物業編號後」。
'findWhere'不適合,如果你有一個目標是挖掘對象 – apneadiving 2014-12-01 19:50:43