1

I have Two Routing in angular2 project:

The first is content list of items I show from Json when press Button, The second is empty for testing only

Issue is when the press in routing the data show items and transport to the two route and comeback to the first the data is remove from the route one

can any one help me to save action in my route one ?

Thank You.

2 Answers 2

2

Might be the issue is ngOnInit will be called only once during router transition. You might be forming the array in ngOnInit. Try to subscribe for Router events inside ngOnInit which will be called while user navigates backs.

ngOnInit(){ 
    this.router.events.subscribe( (event: RouterEvent) => console.log(event));
}
Sign up to request clarification or add additional context in comments.

Comments

1

To import params to URL with :

 this.router.navigate(['/example'],{queryParams:{key1:this.key2,key2:this.key2}})

and To check if parmas is found and get value :

ngOnInit() {
  this.route.queryParams.subscribe(params => {
  this.key1  = params['key1'];
  this.key2 = params['key2'];
}); 
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.