Angular 如何使用anfularfire2/firestore创建分页
我正在尝试创建分页,我希望查询具有动态传递的偏移量和限制(在UI中单击时)的项目。 我用的是收集。是否有任何方法可以从索引和限制(例如5项)开始查询数据 我正在尝试以下方法:Angular 如何使用anfularfire2/firestore创建分页,angular,pagination,angularfire2,Angular,Pagination,Angularfire2,我正在尝试创建分页,我希望查询具有动态传递的偏移量和限制(在UI中单击时)的项目。 我用的是收集。是否有任何方法可以从索引和限制(例如5项)开始查询数据 我正在尝试以下方法: 从“angularfire2/firestore”导入{AngularFirestore}; //其他代码 public getData(offsetFrom,offsetTo){ this.fromQuery$=this.db.collection('transactions',(ref)=>( ref.where('
从“angularfire2/firestore”导入{AngularFirestore};
//其他代码
public getData(offsetFrom,offsetTo){
this.fromQuery$=this.db.collection('transactions',(ref)=>(
ref.where('fromAddress','=',this.fromAddress)
.orderBy('date','asc')
//我想从项目编号开始,但可能无法使用angularfirestore
//其中startAt接受param-字段值
.startAt(3).limit(2)).valueChanges();
}
不可能从索引开始。您必须使用DocumentSnapshot
和startAt
功能。前
publicgetdata(doc:DocumentSnapshot,limit){
this.fromQuery$=this.db.collection('transactions',(ref)=>(
ref.where('fromAddress','=',this.fromAddress)
.orderBy('date','asc')
.startAt(doc).limit(limit)).valueChanges();
}
不可能从索引开始。您必须使用DocumentSnapshot
和startAt
功能。前
publicgetdata(doc:DocumentSnapshot,limit){
this.fromQuery$=this.db.collection('transactions',(ref)=>(
ref.where('fromAddress','=',this.fromAddress)
.orderBy('date','asc')
.startAt(doc).limit(limit)).valueChanges();
}