Whenever I switch tabs and then return to the previous tab in Ionic, the select field that was previously set becomes null, even though the page is still loading and the variable is populated.
<ion-header color="primary">
<ion-navbar>
<ion-title>Planilha</ion-title>
<ion-item color="primary">
<ion-label>Períodos</ion-label>
<ion-select [(ngModel)]="periodoSelecionado" (ionChange)="filtraPeriodo()">
<ion-option *ngFor="let p of periodos" [value]="p">{{p.nome}}</ion-option>
<b>p.nome</b>
</ion-select>
</ion-item>
</ion-navbar>
<ion-searchbar color="primary" (ionInput)="getItems($event)"></ion-searchbar>
</ion-header>
In this scenario, when switching tabs, the value of p.nome does not reload upon returning to the tab unless clicked on again.
TS file:
ionViewDidEnter() {
this.storage.get('apenasMinhasAtividades').then((confApenasMinhasAtividades) => {
if (confApenasMinhasAtividades == null) {
this.confApenasMinhasAtividades = false;
} else {
this.confApenasMinhasAtividades = confApenasMinhasAtividades;
}
});
this.getPlanilha(true, true);
}
getPlanilha(carregarBanco?: boolean, filtraPeriodo?: boolean) {
if (filtraPeriodo == true) {
this.filtraPeriodo();
}
}