OrderByChild и равно не работает в Ionic 3 - PullRequest
0 голосов
/ 16 декабря 2018

В моем HTML

<ion-segment [(ngModel)]="landmarkTag" (ionChange)="changeOption(value)">
      <ion-segment-button value="placesofworship">
        Temples
      </ion-segment-button>
      <ion-segment-button value="museum">
        Museum
      </ion-segment-button>
    </ion-segment>

  <div [ngSwitch]="landmarkTag">
    <ion-list *ngSwitchCase="'placesofworship'">
      <ion-item *ngFor="let chinlandmark of (chinlandmarksRef$ | async)">
          {{chinlandmark.landmarkName}}
      </ion-item>
    </ion-list>

    <ion-list *ngSwitchCase="'museum'">
      <ion-item *ngFor="let chinlandmark of (chinlandmarksRef$ | async)">
          {{chinlandmark.landmarkName}}
      </ion-item>
    </ion-list>
  </div>

В моем TS

changeOption(landmarkTag)
{
    if (this.landmarkTag == 'placesofworship')
    {
      this.chinlandmarksService.getChinlandmarksOption(this.landmarkTag);
    }
    if (this.landmarkTag == 'museum')
    {
      this.chinlandmarksService.getChinlandmarksOption(this.landmarkTag);
    }
  }

В моем сервисе TS

getChinlandmarksOption(landmarkTag)
{
   return this.db.list('chinlandmarksTable', ref => ref.orderByChild('landmarkTag').equalTo(landmarkTag));
}

В то время как мои данные Firebase структурированы следующим образом:

enter image description here

На основании приведенного выше фрагмента моих кодов я могу только получить все свои данные из Firebase, но не могу отсортировать их в соответствии с «landmarkTag».Я даже пытался жестко запрограммировать значение landmarkTag в выражении «equalTo», но все равно не смог получить его.Я не уверен, что не так.Пожалуйста, сообщите .. спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...