I have an angular application In that I have some navigation of routerlinks
My requirement is if the user page is already open with some Id ,and if the condition satisfies in then it has to navigate to that particular ID user page from the existing user page with ID.
.component.ts
if(userID == 0){
this.router.navigate(['./user/' + userID]);
}
else{
this.router.navigate(['./details']);
}
From the above code if I am already in the user page with id then condition satisfies in if condition then we have to navigate to that particular user page with that ID.
Can anyone help me on the same
In order to refresh the current route, in your route declaration you have to do:
Instead, to navigate to another route with params you have to:
1 - Redefine your route
2 - Navigate to page
3 - Get the param from your page
For more information see Angular router and ActivatedRoute