如何使用Ionic3从另一个类重新加载页面

时间:2017-07-04 08:40:36

标签: angular typescript ionic2 ionic3

我有2个文件夹。 /HomePage/SettingsPage

/HomePage包含:

  • home.html的
  • home.ts

/SettingsPage包含:

  • settings.html
  • settings.ts

我想从HompePage

“清理”/重新加载我的home.htmlsettings.ts

我用这个重新加载/刷新settings.html

this.navCtrl.setRoot(this.navCtrl.getActive().component);

1 个答案:

答案 0 :(得分:1)

您可以使用Events

import { Events } from 'ionic-angular';

// SettingsPage (publish an event when you need to reload the HomePage)
constructor(public events: Events) {}

shouldReload() {
  events.publish('shouldReloadData');
}


// HomePage (listen for the event to reload the page)
constructor(public events: Events) {
  events.subscribe('shouldReloadData', () => {
    // Reload the page here
  });
}