MrFlyingToasterman
MrFlyingToasterman

Reputation: 227

How to reload a Page from another class with Ionic3

I have 2 Folders. /HomePage and /SettingsPage.

/HomePage contains:

The /SettingsPage contains:

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

Upvotes: 1

Views: 427

Answers (1)

sebaferreras
sebaferreras

Reputation: 44669

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

Upvotes: 1

Related Questions