How to reload a Page from another class with Ionic3

安稳与你 提交于 2020-01-05 04:11:11

问题


I have 2 Folders. /HomePage and /SettingsPage.

/HomePage contains:

  • home.html
  • home.ts

The /SettingsPage contains:

  • settings.html
  • settings.ts

I want to "clean"/reload my HompePage (home.html) from settings.ts

I reload/refresh my settings.html with this:

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

回答1:


You could use Events for that:

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
  });
}


来源:https://stackoverflow.com/questions/44901083/how-to-reload-a-page-from-another-class-with-ionic3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!