如何使用 Ionic3 从另一个 class 重新加载页面
How to reload a Page from another class with Ionic3
我有 2 个文件夹。 /HomePage
和 /SettingsPage
.
/HomePage
包含:
- home.html
- home.ts
/SettingsPage
包含:
- settings.html
- settings.ts
我想从 settings.ts
"clean"/重新加载我的 HompePage
(home.html
)
我reload/refresh我的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
});
}
我有 2 个文件夹。 /HomePage
和 /SettingsPage
.
/HomePage
包含:
- home.html
- home.ts
/SettingsPage
包含:
- settings.html
- settings.ts
我想从 settings.ts
HompePage
(home.html
)
我reload/refresh我的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
});
}