如何使用Ionic3从另一个类重新加载页面
问题描述:
我有2个文件夹。 /HomePage
和/SettingsPage
。如何使用Ionic3从另一个类重新加载页面
/HomePage
包含:
- home.html的
- home.ts
的/SettingsPage
包含:
- settings.html
- settings.ts
我要 “干净”/重装我HompePage
(home.html
)从settings.ts
我重装/刷新我的settings.html
本:
this.navCtrl.setRoot(this.navCtrl.getActive().component);
答
你可以使用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
});
}
你太棒了!那正是我需要的!非常感谢你:) – MrFlyingToasterman
很高兴听到它帮助:) – sebaferreras