How to invert the order of a ngFor

2

I bring the information of a json that I generate with firebase, and I print it with a ngFor , but it always prints the arrangement from the first to the last one, I would like to do it the opposite.

This is how I get the data

    obtenerdatos(){
    return this.http.get('https://informacion.json');
  }


ionViewDidLoad(){
    this.proveedor.obtenerdatos()
    .subscribe(
      (data)=> {this.rutas = data;},
      (error)=>{console.log(error);}
    )
  }

Here I show you:

<ion-card *ngFor="let ruta of rutas">

<img src="{{ruta.tarjeta}}">
<ion-item>
  <ion-icon name="pin" item-start large></ion-icon>
  <h2>Punto de encuentro:</h2>
  <p>{{ruta.puntodeencuentro}}</p>
</ion-item>

<ion-item>
  <ion-icon name="calendar" item-start large></ion-icon>
  <h2>Fecha:</h2>
  <p>{{ruta.fecha}}</p>
</ion-item>
</ion-card>
    
asked by Talked 03.04.2018 в 19:28
source

1 answer

2

You could simply and simply reverse the order of the arrangement with the method reverse

ionViewDidLoad(){
  this.proveedor.obtenerdatos()
  .subscribe(
    (data)=> {this.rutas = data.reverse();},
    (error)=>{console.log(error);}
  )
}
    
answered by 03.04.2018 / 19:34
source