Reputation: 317
I'm using Nativescript 6 with Angular 8 and I have an issue with the data binded values.
I have two pages. From the first page, I load the values with queryParams:
private getParamData: any;
public ngOnInit() {
this.route.queryParams.subscribe((params) => {
this.getParamData = <any> JSON.parse(params["DataList"]);
});
}
When I move to the second page to return to the first one, the data are first correctly binded and then they are undefined, few seconds later.
How could I preserve the getParamData?
EDIT
Below a link to the Playground for a better understanding: https://play.nativescript.org/?template=play-ng&id=a8XYdf&v=19
When you tap on the Home Label then on the Second Label and finally go back, the Second Label becomes the Third
Upvotes: 0
Views: 313
Reputation: 21908
Preserve the value of query param in a local variable.
this.value = this.route.snapshot.queryParams.yourQueryParamName
Upvotes: 1