javascript - why does the custom component run before the page is created in ionic 2? -


i implement custom component in ionic project , followed this guide realize it.

on page, instantiate variable pass component

export class newsegmentpage {  name: any;  constructor(public navctrl: navcontroller, public navparams: navparams) { this.name = "hello";       } 

and in template

... <ion-content>   <slider [name]="name"></slider> </ion-content> 

now create component

<ion-item>   <ion-range dualknobs="true" pin="true" [(ngmodel)]="structure"></ion-range> </ion-item> 

and retrieve data pass variable @input

@input("coordinates") activity; structure: = { lower: 33, upper: 60 };  constructor() {    console.log(this.activity); } 

but this.activity variable undefined.

in addition, in google console saw component created before page , that's why fails pass data. but, how behave that?

the execution right wrong retrieve this.activity variable in constructor. off of constructor variable instantiated.

ngafterviewinit() {    console.log(this.activity);     } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -