Skip to content

New modular: Paginate a query + Load button #3213

Answered by 7elmon
7elmon asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to find the solution!

import {
  collection,
  collectionData,
  Firestore,
  limit,
  orderBy,
  query,
  startAfter
} from "@angular/fire/firestore";


querySnapshot:any;
lastInResponse:any;


  constructor( private stringEmitted: StringBridgeService, private firestore: Firestore ) {
  }

  ngOnInit(): void {
    this.stringEmitted.stringChanged(this.actualTitle);
    this.loadCustomers('customers', 'name', 5)
  }


  loadCustomers(collectionName:string, order:string, max:number) {
    return collectionData(query(collection(this.firestore, collectionName), orderBy(order), limit(max))).subscribe(
      response => {
        this.lastInResponse = response[response.length - 1];

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 7elmon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant