How to paginate to previous page using AngularFire, Firestore and Firebase

后端 未结 2 1225
迷失自我
迷失自我 2021-02-04 13:34

Sorry I have seen this question has been asked many times in different ways here such as:

  • Howto paginate back to previous pages in a Angular(6) and firebase Fires
2条回答
  •  佛祖请我去吃肉
    2021-02-04 14:01

    As of firebase@7.3.0 you can use the Query.limitToLast(n: number) method - makes it much easier to move backward with paginated data.

    Your implementation details might look something like this:

    function nextPage(last) {
       return ref.orderBy('age').startAfter(last.age).limit(3);
    }
    
    function prevPage(first) {
       return ref.orderBy('age').endBefore(first.age).limitToLast(3);
    }
    

提交回复
热议问题