parkwookyun
parkwookyun

Reputation: 1456

AngularFire - query with startAt/endAt doesn't work

Version info

Angular : 1.5.8
Firebase : 3.2.1
AngularFire : 2.0.1

Test Case

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);
});

Expected behavior

Creates a Query with the specified starting point.

Actual behavior

enter image description here

Upvotes: 0

Views: 438

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599581

Don't use $loaded() and console.log() for debugging the loading of your data when using AngularFire.

Instead bind the users to the scope (you already do that) and then show them in your HTML with:

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

The AngularFire documentation covers this under Handling Asynchronous Operations:

The easiest way to log the data is to print it within the view using Angular's `json filter. AngularFire tells the Angular compiler when it has finished loading the data, so there is no need to worry about when it be available.

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

Upvotes: 1

Related Questions