0

我目前正在使用 Firestore 存储用户数据,并将其镜像到 Algolia 以实现搜索功能。我有以下 HTML 代码显示我的 Algolia 索引中的所有数据:

<ais-instantsearch [config] = "searchConfig">

  <ais-search-box (change)="searchChanged($event)"></ais-search-box>

  <ais-hits *ngIf="showResults">

    <ng-template let-hits="hits">

      <ion-list>

        <ion-item *ngFor="let hit of hits" [routerLink]="['/tabs/home/details', hit.objectId]">
            <ais-highlight attribute="title" [hit]="hit"></ais-highlight>
        </ion-item>
      </ion-list>
    </ng-template>

  </ais-hits>

</ais-instantsearch>

但问题是,在我创建一个新条目并将其添加到我的 Firestore 数据库(Algolia 然后自动镜像)之后,它不会在上面的 html 中更新。如果我在搜索框中搜索它,新条目看起来很好,但是,它没有出现在我在页面上显示的数据条目列表中。

我尝试了离子刷新功能(如下所示),并尝试向其添加 location.reload() ,但这使我回到了我的应用程序的索引页面,而不是当前页面。任何想法如何重新加载我的列表以反映我的 Algolia 数据库中的最新更改?

这是TS:

doRefresh(event) {
  console.log('Begin async operation');

setTimeout(() => {
  console.log('Async operation has ended');
  this.changeRef.detectChanges();
  event.target.complete();
  }, 2000);
}

showResults = true;
4

0 回答 0