0
我刚刚开始使用firebase。我有一个带有id索引的6条记录的文档。 我想查询和同步列表中的前3个项目。Angularfire - Firebase查询/同步文档中的第一个x项目
var metals = new Firebase("https://<dbname>.firebaseio.com/metals").limit(3);
$scope.metals = $firebase(metals);
这提供了列表中的最后3项。不是我想要的。
因此,要获得第一3项,我认为这会工作,但它打破...
var metals = new Firebase("https://<dbname>.firebaseio.com/metals").startAt(1).endAt(3);
$scope.metals = $firebase(metals);
我的数据结构:
{
"metals" : [ null,
{
"id" : 1,
"metal" : "Aluminium",
"element" : "Au"
}, {
"id" : 2,
"metal" : "Silver",
"element" : "Ag"
}, {
"id" : 3,
"metal" : "Copper",
"element" : "Cu"
}, {
"id" : 4,
"metal" : "Tin",
"element" : "Sn"
}, {
"id" : 5,
"metal" : "Nickel",
"element" : "Ni"
}, {
"id" : 6,
"metal" : "Iron",
"element" : "Fe"
}]
}
HTML视图: