Reputation: 734
I searched over and over again, but maybe my search terms were incorrect, because nothing turned up. I want to dynamically show my 404 component depending on the results of an HTTP request.
I realize that I can do this by redirect the user to my 404 page, but is there any way I can render the component without changing the URL?
Something like /people/<nonexistent id>
Thank you!
Upvotes: 4
Views: 872
Reputation: 734
Never mind, I found the answer.
The solution is to userouter.navigate
with the option skipLocationChange
set to true
. This tells Angular to reroute without changing the URL in the browser navbar.
https://angular.io/api/router/NavigationExtras#skipLocationChange
Upvotes: 10