I am trying to navigate to the same component, with different parameters.
I am able to subscribe to the params through the activate Route, but I'm not able to call the router.navigate
within the params from the subscription
sidemenu.component.ts
getTestValue(value:String){
this._router.navigate(['/example/home',value]);
}
home.component.ts
ngOnInit() {
this.route.params.subscribe(params => {
let id = params['id']; // (+) converts string 'id' to a number
console.log("params value"+id)// I am able to get this value but it is
nout ipdating component
this._router.navigate(['/example/home',id]); // This is not getting called
}
I know we have the option to use this
, but I don't want to use this
as this
initiate the other component's ngOnInit
hook.
this._router.routeReuseStrategy.shouldReuseRoute = function() {
return false;
};
https://localhost:4200/example/home/123
https://localhost:4200/example/home/456 // This is not component is not updating