Sort ion-list by date

Asked

Viewed 102 times

0

Good morning, I am studying IONIC with Firebase and created a simple list where I want it to be sorted by update date. In the image we can see that the date is the same as it came from Firebase. inserir a descrição da imagem aqui

I tried to do it this way:

pedidos:any

constructor(){
    // Initialize Firebase
  const config = {
    apiKey: "c",
    authDomain: "c",
    databaseURL: "c",
    projectId: "c",
    storageBucket: "c.c.c",
    messagingSenderId: "c"
  };
  firebase.initializeApp(config);
  this.pedidos = new Array();

  let ref = firebase.database().ref('statuspedido').orderByChild('dataAtualizacao');//statuspedido
 ref.on('value', (dataSnapshot) =>{
     let items = dataSnapshot.val();
     for(let dados in items){
        this.pedidos.push(
            new PedidoModel(
                items[dados].idPedido,
                items[dados].dataEmissao,
                items[dados].dataAtualizacao,
                items[dados].vendedor,
                items[dados].frete,
                items[dados].transportadora,
                items[dados].status)
        )
     }
  })
}

and at firebase:

inserir a descrição da imagem aqui

  • related: https://answall.com/questions/235413/order-do-mais-recente-para-o-mais-antigo-no-firebase

  • reading: https://firebase.google.com/docs/firestore/query-data/order-limit-data?hl=pt-br

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.