我可以在时间和第二个循环中返回10条记录,拉出10条不同的记录吗?

时间:2017-03-30 02:42:01

标签: javascript loops angular firebase firebase-realtime-database

这是我用来从Firebase提取数据并在下面运行循环的代码。

loadPeople() {

    return new Promise(resolve => {

      this.dataProvider.getProducts().subscribe((products) => {
        this.start;
        this.products = products;
        this.AKey = products.pop().$key;

        console.log(products);
        for(let person of products) {
          this.people.push(person);
        }

        resolve(true);

      });

    });

  }

    doInfinite(infiniteScroll:any) {
     console.log('doInfinite, start is currently '+this.start);
     this.start+=50;

     this.loadPeople().then(()=>{
       infiniteScroll.complete();
     });

  }

}

1 个答案:

答案 0 :(得分:0)

我没有正确使用promises。请在下方查看如何使用Firebase对promises进行分页。 https://howtofirebase.com/firebase-data-structures-pagination-96c16ffdb5ca

-3.24198 1.03606 1.14794 118 123 116 -0.0810083 -0.0129849 -0.996629