更新algolia数据后如何刷新html?

时间:2019-04-23 05:06:50

标签: firebase ionic-framework google-cloud-firestore ionic4 algolia

我目前正在使用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;

0 个答案:

没有答案