首页 > 解决方案 > orderBy 不使用 .startAfter(this.lastInResponse)

问题描述

我正在使用分页。On ngOnInit(),它正在按预期以正确的顺序获取数据,请参见下面的代码 -

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

但是当我尝试NextPage()使用下面的代码点击功能时,我没有收到任何结果

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()

为什么我在这里没有得到任何结果?请注意,如果我删除 order by,我会得到结果,但不会在 nextpage 函数中使用它。

标签: javascriptfirebasegoogle-cloud-firestoreangularfire2

解决方案


推荐阅读