1

I am using pagination. On ngOnInit(), it is fetching data with proper ordering as expected, see code below -

    this.firestore.collection('complaints' , ref => ref 
.where("complaint_status", "==", "Open")
.limit(8)
.orderBy('ticketid', 'desc')
).snapshotChanges()
.subscribe(response => {

But whenI try to use this on clicking NextPage() function using below code, I dont receive any result

nextPage(){
        console.log("show next. data");
        this.disable_next = true;
        this.firestore.collection('complaints', ref => ref
        .where("complaint_status", "==", "Open")
        .limit(8) 
        .orderBy('ticketid', 'desc')
        .startAfter(this.lastInResponse)
        ).get()

Why am I not getting any result here? Note that if I remove order by, I do get results, but not getting with it on nextpage function.

halfer
  • 19,824
  • 17
  • 99
  • 186
user2828442
  • 2,415
  • 7
  • 57
  • 105
  • So far, I see nothing wrong with your nextPage() function. As mentioned [here](https://stackoverflow.com/questions/57375231/firestore-startafter-returning-the-same-data-in-infinite-scrolling-when-ordere#answer-57386970) the startAfter() is expecting a query cursor for the parameter, which from your code seems to be lastInResponse. The information you provided does not include the value of the lastInResponse. I suggest you review that or update this thread with this info. – oakinlaja Jul 29 '20 at 12:19
  • If i remove orderby, it works fine, if i add it, it doesnt return any data , what next should i do ? – user2828442 Jul 30 '20 at 04:35
  • Take a look at this post about Firestore + AngularFire2 pagination [1]. There is a section with examples using the Next Page method. [1] https://www.thetopsites.net/article/50083771.shtml – Rajeevan Aug 17 '20 at 18:18

0 Answers0