Guest User

Untitled

a guest
Nov 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. _get_brands_(cursor, direction) {
  2.  
  3. if ( direction === 'next') {
  4.  
  5. if ( cursor === 0) {
  6. this.brands_collection = this.afs.collection('brands', ref =>
  7. ref.orderBy('created')
  8. .limit(5)
  9. );
  10. return this.brands = this.brands_collection.valueChanges();
  11.  
  12. } else {
  13.  
  14. this.brands_collection = this.afs.collection('brands', ref =>
  15. ref.orderBy('created')
  16. .startAfter(cursor)
  17. .limit(5)
  18. );
  19. return this.brands = this.brands_collection.valueChanges();
  20. }
  21.  
  22. } else if (direction === 'back') {
  23.  
  24. console.log('Back pagination start ==> ', cursor);
  25. this.brands_collection = this.afs.collection('brands', ref =>
  26. ref.orderBy('created')
  27. .endBefore(cursor)
  28. .limit(5)
  29. );
  30.  
  31. return this.brands = this.brands_collection.valueChanges();
  32. }
  33. }
Add Comment
Please, Sign In to add comment