如何使用Ionic3从另一个类重新加载页面 [英] How to reload a Page from another class with Ionic3

查看:368
本文介绍了如何使用Ionic3从另一个类重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个文件夹。 / HomePage / SettingsPage

I have 2 Folders. /HomePage and /SettingsPage.

/ HomePage 包含:


  • home.html

  • home.ts

/ SettingsPage 包含:


  • settings.html

  • settings.ts

我想从<$重新加载我的 HompePage home.html ) c $ c> settings.ts

I want to "clean"/reload my HompePage (home.html) from settings.ts

我重新加载/刷新我的 settings.html 用这个:

I reload/refresh my settings.html with this:

this.navCtrl.setRoot(this.navCtrl.getActive().component);


推荐答案

您可以使用事件

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

这篇关于如何使用Ionic3从另一个类重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆