Hello everyone, I’m trying to pass a parameter from the main page to the Tabs through the rootParam, but it is not working. Below is the code:
profile.ts
@IonicPage()
@Component({
selector: 'page-perfil',
templateUrl: 'perfil.html',
})
export class PerfilPage {
tab1 : any;
tab2 : any;
tab3 : any;
public profile : ProfileDTO;
constructor(public navCtrl: NavController,
public navParams: NavParams,
public usuarioService: UsuarioService)
{
this.tab1 = 'GeralProfilePage';
this.tab2 = 'EnderProfilePage';
this.tab3 = 'OtherProfilePage';
this.navParams.data = this.profile
}
ionViewDidLoad() {
this.showProfile();
}
showProfile() {
this.usuarioService.getProfile().subscribe(
response => {
this.profile = response;
},
error => {console.log(error)}
);
}
}
As you can see, the profile is retrieved in subscribe. So in the constructor I try to extrude it to this.profile. Below is the html (profile.html):
<ion-content padding>
<ion-tabs color="primary">
<ion-tab [root]="tab1" tabIcon="information-circle" [rootParams]="profile"</ion-tab>
<ion-tab [root]="tab2" tabIcon="home" [rootParams]="profile"></ion-tab>
<ion-tab [root]="tab3" tabIcon="bookmarks" [rootParams]="profile"></ion-tab>
</ion-tabs>;
</ion-content>;
finally the files referring to the first tab as an example:
geral-profile.html
<ion-content padding>
nome: {{profile?.nome}}
</ion-content>
geral-profile.ts
@IonicPage()
@Component({
selector: 'page-geral-profile',
templateUrl: 'geral-profile.html',
})
export class GeralProfilePage {
profile: any;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.profile = navParams.data
console.log(this.navParams)
}
ionViewDidLoad() {
}
}
The parameter value is empty. How to pass the value returned in subscribe to the this.profile parameter, and then send it to the tabs?
Tks,