I am using the Angular2 CustomReuseStrategy class to save an instance of a component. When I first go to the component, a new instance is created. This works as expected. However, when I head to the same component with the new parameters, a new instance of this component is created, and the onInit functions are executed again. I would like the component to use the same instance, but update the URL parameters. Any ideas? I am stuck on this.
Here are my routes.
{ path: 'tiles', component: DisplayTileData },
{ path: 'tiles/:master/:filters', canActivate: [AuthGuard], component: DisplayTileData }
The following are ways to get to these routes.
addNewMasterPath(newMasterVariable) {
this.master = this.master + '-' + newMasterVariable;
var newMap = this.variable.map(items => { return items}).join('-');
this.router.navigate(['tiles', this.master, newMap]);
}
onSelectAddNewParameter(newParameter) {
this.variable.push(newParameter);
var newMap = this.variable.map(items => { return items}).join('-');
this.router.navigateByUrl('/tiles/this.master/newMap');
}
Just to be clear, the behavior is the same if I use router.navigate or router.navigateByUrl.