First ion-tabs tab does not show data

Asked

Viewed 56 times

0

I have the following template with two tabs

  <ion-tabs  tabsPlacement="top" color="primary" #entradaSaidaTabs >
    <ion-tab [root]="tabReceber"  [rootParams]="paramsChart" tabTitle="Entrada"></ion-tab>
    <ion-tab [root]="tabPagar" [rootParams]="paramsChart" tabTitle="Saída"></ion-tab>
  </ion-tabs>

The variable passed via rootParams, paramsChart, receives the data of an api through the function carregaMovimentacoes().

paramsChart: any;

ionViewDidLoad() {
  this.carregaMovimentacoes();
}

When the page is active, only the second tab shows the list with the data, the first one remains blank. The strange thing is that they both receive the same variable via rootParams, but in the first tab it is undefined, while in the second, she has the list with the data.

 ionViewDidEnter() {
    this.paramsChart = this.navParams.data; // Recebe o os parametros da pagina raiz
  }

How to display the list with the data also in the first tab?

1 answer

1


After obtaining the data via API, pass them to the tab via publish()

this.events.publish("paramsChart:changed", paramsChart);

In the first tab, sign up, and wait for the event response

 this.events.subscribe("paramsChart:changed",(res) => {
    this.paramsChart = res;
 });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.