Trung Bui
Trung Bui

Reputation: 180

How to use $firebaseArray in firebase return data in AngularJS

I want to retrieve data from firbase with a condition like this

ref.orderByChild('users').equalTo(userid).on('value', function(snapshot) {
    // Need to return data as firebaseArray here
});

$firebaseArray is very useful when we want to show data on view. But I don't know how to return the snapshot there.

Please help me ! (bow)

Upvotes: 1

Views: 515

Answers (1)

David East
David East

Reputation: 32604

A $firebaseArray can take in a ref or a query.

var query = ref.orderByChild('users').equalTo(userid);
var syncArray = $firebaseArray(query);

The array function handles all the child events and keeps the array in sync with the remote server changes.

Upvotes: 1

Related Questions