Display posts in descending posted order

前端 未结 18 1158
南方客
南方客 2020-11-22 11:47

I\'m trying to test out Firebase to allow users to post comments using push. I want to display the data I retrieve with the following;

fbl.child         


        
18条回答
  •  一整个雨季
    2020-11-22 12:20

    just use reverse() on the array , suppose if you are storing the values to an array items[] then do a this.items.reverse()

     ref.subscribe(snapshots => {
           this.loading.dismiss();
    
          this.items = [];
          snapshots.forEach(snapshot => {
    
            this.items.push(snapshot);
    
          });
          **this.items.reverse();**
        },
    

提交回复
热议问题