rahulrsingh09/AngularConcepts

Return Comments in reverse order from Firebase after edit delete or Refresh

rahulrsingh09 opened this issue · 0 comments

When the component loads for the first time it happens fine.

  fetchData(){
    return this.af.list('/path/path/',{
      query: {
        orderByChild: 'createdAt'
      }
    }).map(arr => {return arr.reverse();});
  }

The data from fetch ads is stored in a var and then displayed.

But now the problem is the var is modified at run time the user can update the var array , or delete or add to it .

And when ever any of these operations takes place the data is modified on the firebase db and that calls the fetch data again .

But then the reverse is again revesed rendering the whole thing use less.

By this i mean is after the first component load the var is 1,2,3,4. But then when we add to var instead of becoming 1,2,3,4,5 it becomes 5,4,3,2,1.

This is very confusing but i a tried lot but not able to fix this.