Ionic framework 从另一个页面/模式重新加载页面

Ionic framework 从另一个页面/模式重新加载页面,ionic-framework,ionic3,Ionic Framework,Ionic3,编辑 我注意到订阅事件必须在发布和调用之前先出现。但每次应用程序启动时要求用户打开选项卡页面将是愚蠢的 我不需要总是重新加载选项卡页面,因此我需要这种事件类型的方法来完成这项工作。或者我们可以在IonViewDiCenter()上调用重载 我有两个标签和一个模式/TabIn、/TabOut和/ModalIn 选项卡页面用作数据列表,在ionViewDidLoad()上显示数据库中的数据 ModalIn页面作为数据输入,供用户输入和提交数据。此页面位于页面的选项卡中,当用户单击每个数据列表时,

编辑

我注意到订阅事件必须在发布和调用之前先出现。但每次应用程序启动时要求用户打开
选项卡页面将是愚蠢的


我不需要总是重新加载
选项卡页面
,因此我需要这种事件类型的方法来完成这项工作。或者我们可以在
IonViewDiCenter()
上调用重载


我有两个标签和一个模式/TabIn、/TabOut和/ModalIn

选项卡页面
用作数据列表,在
ionViewDidLoad()
上显示数据库中的数据

ModalIn页面
作为数据输入,供用户输入和提交数据。此页面位于页面的
选项卡中,当用户单击每个数据列表时,将调用此页面

ModalIn页面
中成功提交表单后,我想在
选项卡页面
上再次调用refresh(无论之前是否已加载)。我尝试使用事件发布,但它不起作用。下面是我的代码

ModalIn.ts

let headers: any = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' }),
options: any = { "username": val, formValue },
url: any = "some_url_here";

this.http.post(url, options, headers)
.subscribe((data: any) => {

  if (data.status == 'success') {
    this.events.publish('shouldReloadData');
  } else {

  }
},
  (error: any) => {
    console.log(error);
  });
constructor(public events: Events) {
  events.subscribe('shouldReloadData', () => {
    // Reload the page here
    console.log("should reloadddd"); // <- This is not working
  });
}
TabOut.ts

let headers: any = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' }),
options: any = { "username": val, formValue },
url: any = "some_url_here";

this.http.post(url, options, headers)
.subscribe((data: any) => {

  if (data.status == 'success') {
    this.events.publish('shouldReloadData');
  } else {

  }
},
  (error: any) => {
    console.log(error);
  });
constructor(public events: Events) {
  events.subscribe('shouldReloadData', () => {
    // Reload the page here
    console.log("should reloadddd"); // <- This is not working
  });
}
构造函数(公共事件:事件){
订阅('shouldReloadData',()=>{
//在这里重新加载页面

console.log(“应该重新加载ddd”);//调用
subscribe
,使用
this
关键字inside TabOut.ts

constructor(public events: Events) {

  this.events.subscribe('shouldReloadData', () => {

  });
}