I want to filter some data from the FirebaseListObservable but I don't know how to perform it. For the normal case here is the solution but using the real time database it doesn't work. Please help.
-
In that case just use this Search filter. You will get the expected result. But if not then whatever you have tried just post it hereThe Hungry Dictator– The Hungry Dictator2017-04-21 05:07:21 +00:00Commented Apr 21, 2017 at 5:07
-
i fetch my data from the database like this *ngFor="let pos of post | async" it works but i want to make some filter by search bar i added the filter pipe like this *ngFor="let pos of post | async | searchFilter: search.value " but it doesnt workSofiene Ben Khemis– Sofiene Ben Khemis2017-04-21 14:04:38 +00:00Commented Apr 21, 2017 at 14:04
Add a comment
|
1 Answer
It is very ineffective to make a query for the whole list and filter it on client side. You need to make a query with parameters, so you will get only needed data in your subscription. Example is below, different query parameters can be inserted to query object. More info about query parameters can be found here: https://firebase.google.com/docs/reference/js/firebase.database.Query
export class AppComponent {
constructor(af: AngularFire) {
let listWithQuery = af.database.list('/items', {
query: {
equalTo: 'something',
orderByKey: true
}
});
}
}
1 Comment
Sofiene Ben Khemis
equalTo don't give everything that is included in the search bar , it just give the same exact word of the key value in the database but in my case i wanna to search in all the collection