I am checking some localstorage info and depending on the info I get I want to load the appropriate page.
So in my app.component.ts
I have the following.
export class MyApp {
rootPage: string;
constructor(){
if(dataFound)
this.rootPage="HomePage"
else
this.rootPage="OtherPage"
}
}
Is there a way I can pass data when setting the this.rootPage
.
Keep in mind that this is the initial load of the app. If this happen after the app has loaded I can do this.navCtrl.setRoot()
which will allow me to pass parameters along with the page.
Any help is appreciated.
Thanks
As @gaborp said, but with a little difference :
In your root:
<ion-nav [root]="rootPage" [rootParams]="rootPageParams"></ion-nav>
this.rootPageParams = {'username': "David" }
In the view you want to read that param (this is the difference):
this.username = this.nav['rootParams'].username;
All I read was about tabs, but nothing for a simple ion-nav, so that is the way I did it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With