我有一个问题。Firebase似乎为使用push()方法创建的对象生成唯一的id。虽然这很神奇,但官方教程似乎忽略了如何基于该唯一id检索对象的简单问题。
{
"contacts" : {
"-KD3p6kdEUbg38X7Osfm" : {
"address" : "Whitley rd 22, Northampton",
"email" : "somethingsatsomething@soso",
"name" : "George Booney",
"notes" : "Sounds like a serious businessman",
"phone" : "01239485764",
"website" : "http://www.workingatthepumps.com"
},
"-KD3pzA_P3pK0TCzg4zw" : {
"address" : "Common Avenue 22, Birmingham",
"email" : "johnyoeias@nowhereas.com",
"name" : "John Doe",
"notes" : "Sounds like a serious businessman",
"phone" : "44582314864",
"website" : "http://www.wearelost.com"
}
}
}
调用它的代码如下所示:
var ref = new Firebase("https://contactsmgr.firebaseIO.com/contacts");
return {
get: function() {
return ref;
},
find: function() {
// the required code to refer to the unique id
}
};
有简单的方法来做这件事吗?还是我创建的JSON结构本质上就是错误的?
$scope.contact = $firebaseObject(ref.child('-KD3pzA_P3pK0TCzg4zw'))
。 - Frank van Puffelen