问题
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