如何查询firebase以检索唯一ID

时间:2014-12-20 02:51:20

标签: javascript firebase angularfire

我使用以下代码从Firebase查询数据:

var firebaseObj = new Firebase("https://example.firebaseio.com/Articles");

var sync = $firebase(firebaseObj);

$scope.articles = sync.$asArray();

返回以下数据:

    [{
    "emailId": "ty@ty.com",
    "post": "fgh",
    "title": "hfgh"
}, {
    "emailId": "kj@hjgfh.com",
    "post": "HHHHHH",
    "title": "Hello"
}, {
    "emailId": "hkj@gmail.com",
    "post": "Big news",
    "title": "Today's news"
}]

https://example.firebaseio.com/Articles下的每个返回条目都有一个唯一的ID,该ID在返回的结果中缺失。 如何检索唯一ID。

1 个答案:

答案 0 :(得分:5)

尝试使用特殊的$id属性,即相对唯一的firebase密钥。

相关问题