0
I’m trying to perform a search with Ionic 3 + Angularfire2. I have a list of all the data from firebase, but I can’t filter this data, it does not return me anything.
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
}
});
}
file . html
<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.