我尝试使用以下代码将数据推送到firebase,并且工作正常。
var firebaseObj = new Firebase("https://burning-fire-1723.firebaseio.com/Articles");
var fb = $firebase(firebaseObj);
fb.$push({
title: "title",
post: "post",
emailId: "mymail@gmail.com"
}).then(function(ref) {
console.log(ref);
}, function(error) {
console.log("Error:", error);
});
接下来,为了从Firebase获取特定记录,我需要在推送数据时为emailId字段分配优先级。 但我真的无法弄清楚如何做到这一点。 任何帮助将不胜感激。
答案 0 :(得分:0)
这应该为你做。
var user = "mymail@gmail.com";
var firebaseObj = new Firebase("https://burning-fire-1723.firebaseio.com/Articles");
var fb = $firebase(firebaseObj);
fb.$push({
title: title,
post: post,
emailId: user,
'.priority': user
}).then(function(ref) {
console.log(ref);
$location.path('/welcome');
}, function(error) {
console.log("Error:", error);
});
答案来自this tutorial。