概述:
当我的页面加载到 Ionic 2 应用程序中时,我发出网络请求以填充列表。此时此刻,当页面最初加载时,我正在切换一个 ionic 微调器。这是目前的复习:
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content
pullingText="Pull to refresh..."
refreshingSpinner="circles">
</ion-refresher-content>
</ion-refresher>
<ion-spinner *ngIf="loading" color="light" name="circles"></ion-spinner>
我想要的行为是删除 ionic 旋转器组件,并在页面最初加载时启用 ionic 刷新器。我已经在 Ionic V1 中看到过几个这样的例子,但我似乎无法将其转换为 Angular 2。
问题:
有没有办法从我的 Controller (*.ts) 触发 ionic 刷新器及其微调器,这样我就可以从我的模板中删除额外的 ionic 微调器组件?
最佳答案
我实际上发现了一个 hack:
import { Content, Refresher } from 'ionic-angular';
export class MyPage {
@ViewChild(Content) content: Content;
@ViewChild(Refresher) refresher: Refresher;
...
ionViewDidEnter() {
this.refresher._top = this.content.contentTop + 'px';
this.refresher.state = 'ready';
this.refresher._onEnd();
}
这将显示并触发更新。它隐式调用已注册的刷新函数。
关于javascript - Ionic 2 Refresher 在页面加载时切换 ionic 刷新器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42797392/