在Firebase集合AngularFire 0.6.0中保存并获取$ item的优先级

时间:2014-02-03 18:48:44

标签: javascript angularjs firebase angularfire

假设我有一系列项目

var itemsRef = new Firebase("https://example.firebaseio.com/items");  
$scope.items = $firebase(itemsRef);

我想用$priority

将新项目保存到集合中
$scope.items["thing"] = {name:'The Thing'};
$scope.items["thing"].$priority = 1;
$scope.items.$save("thing");

到目前为止一切都很好 - 我可以在我的收藏中看到新项目。

现在让我们抓取它并找出我刚刚分配给它的$priority

var thingRef = new Firebase("https://example.firebaseio.com/items/thing");  
$scope.thing = $firebase(thingRef);
$scope.thing.$on("loaded", function() {
  console.log($scope.thing);
});

它向我们展示了控制台中没有 a $priority的Firebase对象。

但是,如果我们这样做:

//After saving the "thing" $priority
$scope.items.$on("loaded", function() {
  console.log($scope.items);
});

您将看到子节点及其$priority

保存和获取Firebase集合项的优先级的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

这是一个已经解决的错误: https://github.com/firebase/angularFire/issues/243