离子火力基地过滤器数据

时间:2018-08-30 11:44:31

标签: javascript angular firebase firebase-realtime-database angularfire2

我正在尝试从instituicao过滤数据,我在做什么错呢? 没有显示任何错误

<ion-searchbar showCancelButton="true" [(ngModel)]="queryText" [showCancelButton]="shouldShowCancel" placeholder="Pesquisar por nome"
    (ionInput)="filterData()">
  </ion-searchbar>

  <div>
    <ion-card *ngFor="let instituicao of instituicoes | async">
      <ion-item>
        <ion-avatar item-start>
          <!-- html code... -->

这是home.ts,当我在搜索栏中搜索某些内容时,请调用函数filterData

export class HomePage {

  private PATH = 'instituicoes/';

  queryText: string;
  instituicoes: Observable<any[]>;


  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public http: Http,
    private provider: InstituicaoProvider,
    private afDb: AngularFireDatabase) {
    this.instituicoes = this.provider.getAll();
  }
filterData() {
    console.log(this.queryText);
     return this.afDb.list(this.PATH, ref => ref.equalTo(this.queryText)).snapshotChanges();
  }

和发起人:

//imports
    private PATH = 'instituicoes/';

      constructor(private db: AngularFireDatabase, public alertCtrl: AlertController) {

      }

      getAll() {
        return this.db.list(this.PATH, ref => ref.orderByChild('ong'))
          .snapshotChanges()
          .map(changes => {
            return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
          })
      }
//others functions

0 个答案:

没有答案