В моем 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](https://i.stack.imgur.com/pDG9j.jpg)
На основании приведенного выше фрагмента моих кодов я могу только получить все свои данные из Firebase, но не могу отсортировать их в соответствии с «landmarkTag».Я даже пытался жестко запрограммировать значение landmarkTag в выражении «equalTo», но все равно не смог получить его.Я не уверен, что не так.Пожалуйста, сообщите .. спасибо!