1

I have an Angular 5 application. Say a route is loaded for e.g. http://localhost:3000/ui/customers/9/billing

if i refresh the page in the browser, it automatically goes to the http://localhost:3000/ui/customers/9/billing component; is there any way to make it load the http://localhost:3000/ui/customers route (component)?

I have tried using HashLocationStrategy but it is not working.

The question here is the same, but i did not understand the solution provided.

Viking22
  • 545
  • 1
  • 7
  • 19
  • Why would it be a good idea, if a user decides to refresh the current page, to go to a different page than the one he/she explicitly asked to refresh? – JB Nizet Sep 15 '18 at 20:13
  • If he refreshes the page, i want him to start over by visiting the parent route /customers. Or to the root of the application – Viking22 Sep 15 '18 at 20:14
  • Yes, I understand that. My point is that it's a bad idea. If I ask to refresh the current page, it's because I want to refresh the current page. Not because I want to go elsewhere. If someone goes to a bar and asks for a beer, and gets a coke instead, that's not right. – JB Nizet Sep 15 '18 at 20:16
  • Besides the fact, that i also think this it not a good idea in general - the solution would be to redirect to your "root" page within the constructor of you app.component.ts – Patrick Kelleter Sep 15 '18 at 20:18
  • @AJT_82 provide the best solution on your shared question link. https://stackoverflow.com/questions/47234250/angular-5-redirect-page-to-homepage-on-browser-refresh – Shashikant Devani Sep 15 '18 at 20:18
  • Got it thanks. it works now. – Viking22 Sep 15 '18 at 20:31
  • actually the router loses any sense here. The whole point of router is having persistent URLs that are keeping the connection to the view. By resetting it on any URL call you just, well, destroy the whole idea – smnbbrv Sep 15 '18 at 21:23

0 Answers0