如何使用Ionic3从另一个类重新加载页面

问题描述:

我有2个文件夹。 /HomePage/SettingsPage如何使用Ionic3从另一个类重新加载页面

/HomePage包含:

  • home.html的
  • home.ts

/SettingsPage包含:

  • settings.html
  • settings.ts

我要 “干净”/重装我HompePagehome.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 
    }); 
} 
+1

你太棒了!那正是我需要的!非常感谢你:) – MrFlyingToasterman

+0

很高兴听到它帮助:) – sebaferreras