javascript - Ionic 2 Refresher 在页面加载时切换 ionic 刷新器

标签 javascript html angular ionic2

概述:

当我的页面加载到 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/

相关文章:

javascript - 使用 Vuejs 中的 Api 响应映射 Json 文件

html - 向 HTML5 Canvas 添加碰撞

javascript - 在 ('change' 上)未触发

具有严格类型检查的 Angular 全局 trackBy 属性指令

angular - 如何以 Angular 向条件添加多个类

angular - 删除数据表 Angular 中的空行

javascript - 如何通过 phantomJS 实时渲染 javascript?

javascript - 我在某处缺少 Javascript cron 实现吗?

javascript - ExtJS 主题修改 Ext.panel.Panel

html - 表格单元格上的 CSS 插入框阴影未对齐