2016-09-21 32 views
0

版本信息AngularFire - 與startAt/ENDAT查詢不起作用

角:1.5.8
火力地堡:3.2.1
AngularFire:2.0.1

測試用例

var path = {}; 
    path.users ='/users' 

var reference = {}; 
    reference.users = firebase.database().ref(path.users).startAt(0).endAt(10) 

$scope.items ={} 
$scope.items.users = $firebaseArray(reference.users); 

$scope.items.users.$loaded().then(function(object){ 
    console.log(object); 
}); 

預期行爲

用指定的起點創建查詢。

實際行爲

enter image description here

回答

1

不要使用$loaded()console.log()使用AngularFire時調試數據的加載。

取而代之的是用戶綁定到範圍(你已經這樣做),然後向他們展示在你的HTML:

最簡單的方法:

<pre>{{ items.users | json }}</pre> 

的AngularFire文檔涵蓋本Handling Asynchronous Operations下記錄數據是使用Angular的json過濾器在視圖中打印數據。 AngularFire告訴Angular編譯器加載數據的時間,因此不需要擔心它何時可用。

<pre>{{ data | json }}</pre> 
0

請在您的HTML添加此。

<pre>{{ data | json }}</pre> 

<pre>{{ data | json | async }}</pre>