Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

NavParams: undefined parameter caused by double (automatic?) load of a page

$
0
0

@Stickse wrote:

Hi to everyone,
i'm trying to send a parameter from a first component to a second component in this way (only relevant code of first component, if i try this.navCtrl.setRoot etc i get the same effect):

this.navCtrl.push(SecondComponent,{infodata: "val" });

In my second component (only relevant code):

datarec;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.datarec=this.navParams.get('infodata');
console.log(this.datarec);
}

in my console i can see:
val
undefined

So this code is called two times and the problem is that i can't use my parameter because it's always undefined. My questions:
Why it's called two times? What can make reload the page of the second component?
thanks who will try to help.

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles