Problem to get an item from an AngularFireList

0

I can not get an object when I try to look for it through one of its attributes (code) in an AngularFireList. What do you recommend?

COMPONENT

 this.prestamoService.obtenerPrestamo("P34520181127")
    .snapshotChanges()
       .subscribe(item => {
         this.prestamoLista = [];
         item.forEach(element =>{
           let x = element.payload.toJSON();
           x["$key"]  = element.key;
           this.prestamoLista.push(x as Prestamo);
         });
       });

SERVICE

import { Injectable } from '@angular/core';

import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';

import { Prestamo } from '../models/prestamo';
import { FirebaseDatabase } from 'angularfire2';

@Injectable({
  providedIn: 'root'
})
export class PrestamoService {

  prestamoLista: AngularFireList<any>;
  prestamoSeleccionado: Prestamo = new Prestamo();

  constructor(private firebase: AngularFireDatabase) {}

  obtenerPrestamo(codigo: string)
  {
    return this.prestamoLista = this.firebase.list('prestamos', ref =>ref.orderByChild('codigo').equalTo(codigo));
  }
}

I need to get a particular loan from the method 'getPrest ()'.

    
asked by Leonardo 04.01.2019 в 19:00
source

0 answers