queries on Ionic 3 using AngularFire2

0

I'm trying to perform a search with ionic 3 + AngularFire2. I have a list with all the data of the firebase, however I can not make a filter of this data, it does not return anything to me.

file.ts

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

dashboardData: FirebaseListObservable<any>;

constructor(private afDatabase:     AngularFireDatabase) {

  this.dashboardData = this.afDatabase.list('/motoristas');
}

getRota(rota: string){
this.dashboardData = this.afDatabase.list('motoristas', {
  query: {
    orderByChild: 'rota',
    equalTo: rota
  }
});
}

.html file

<ion-list>
    <ion-item>
        <ion-label>Rota</ion-label>
        <ion-select [(ngModel)]="rota" (ionChange)="getRota(rota)">
            <ion-option value="Caruaru">Caruaru</ion-option>
            <ion-option value="Belo Jardim">Belo Jardim</ion-option>
        </ion-select>
    </ion-item>
</ion-list>

<ion-list>
    <ion-item *ngFor="let motorista of dashboardData | async" (click)="showOptions(country.$key, country.nomeMotorista)">

        <ion-thumbnail item-start>
            <img src="./assets/img/icon.svg">
        </ion-thumbnail>
        <h2>{{ motorista.nomeMotorista }}</h2>
        <p> {{ motorista.rota }} </p>
        <button ion-button clear item-end color="outro"> <ion-icon ios="ios-people" md="md-people"> {{ motorista.numPassageiros }} </ion-icon></button>
    </ion-item>
</ion-list>

I have no return.

    
asked by anonymous 28.08.2017 / 19:07

1 answer

0

Hello, Friend could show how your bank is:

Because I search like this:

 private PATH = 'produtos/'
...

get (key: string ){
return this.db.list(this.PATH, ref => ref.orderByChild('codigo').equalTo(key))
  .snapshotChanges()
  .map (Changes => {
    return Changes.map(p => ({
       key: p.payload.key, ...p.payload.val()}));
    })
  } 
    
12.03.2018 / 17:12