Someone already used ng-table on angular and could figure out how to use it with firebase collecction?
I'm trying to use ng-table (last example) to sort and filter my collection on Angular 10, so I tried to just change the constant in the code to my object and I it did not work. I think I need to convert my object to an array, so I tried this library to do it, and also dont work. Also tried to look for this on stackoverflow and all I find out is others with the same problem.
This is the exact function where I need to do this. COUNTRIES is the array that comes from *countries.ts. The function bellow is on country.service.ts.
private _search(): Observable<SearchResult> {
const {sortColumn, sortDirection, pageSize, page, searchTerm} = this._state;
// 1. sort
let countries = sort(COUNTRIES, sortColumn, sortDirection);
// 2. filter
countries = countries.filter(country => matches(country, searchTerm, this.pipe));
const total = countries.length;
// 3. paginate
countries = countries.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize);
return of({countries, total});
}
}
That is what I tried with the lib that found out:
this.items = this.firestore.collection('users').valueChanges();
alert( O2A(this.items) );
But it does not work for me.
Thank's!
this.items.subscribe(res => alert(O2A(res))). Don't forget to unsubscribe once you don't need it, otherwise, you will create a data leak in your app which will be terrible for your app performance.