【问题标题】:How to reload a Page from another class with Ionic3如何使用 Ionic3 从另一个类重新加载页面
【发布时间】:2017-12-07 15:18:51
【问题描述】:

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

/HomePage 包含:

  • home.html
  • home.ts

/SettingsPage 包含:

  • settings.html
  • settings.ts

我想从settings.ts“清理”/重新加载我的HompePage (home.html)

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

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

【问题讨论】:

    标签: angular typescript ionic2 ionic3


    【解决方案1】:

    您可以为此使用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
      });
    }
    

    【讨论】:

    • 你太棒了!这正是我需要的!非常感谢:)
    • 很高兴听到它有帮助:)
    猜你喜欢
    • 2016-11-17
    • 1970-01-01
    • 1970-01-01
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多