PatrickJS-starter icon indicating copy to clipboard operation
PatrickJS-starter copied to clipboard

Changing URL manually is triggering a refresh

Open pagadalasrikanth opened this issue 8 years ago • 4 comments

  • I'm submitting a ... [ ] bug report

  • Do you want to request a feature or report a bug? Report a Bug

  • What is the current behavior? Whenever the URL is changed manually, the entire app is reloaded.

[EDIT] .. The app is initially loaded with http://localhost:3000/home and then the user replaces the "home" with "details". The app should redirect the user to the details page instead of reloading the entire app.

  • What is the expected behavior? If the new URL matches any of the existing routes, the app should navigate the user to the required page.

  • What is the motivation / use case for changing the behavior? Issue

  • Please tell us about your environment:

  • Angular version: 5.1.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

pagadalasrikanth avatar Jan 17 '18 12:01 pagadalasrikanth

Do you mean manually by changing it on your browser in the address bar? If so, that’s not part of how Angular or the browser is supposed to work.

Bjeaurn avatar Jan 21 '18 15:01 Bjeaurn

@Bjeaurn .. The app loads initially with the url http://localhost:3000/home and then i manually replace "home" to "details".. In this case why should the app reload ?

pagadalasrikanth avatar Jan 21 '18 15:01 pagadalasrikanth

Explain what you mean with manually? Do you change the URL in the browser address bar? It’s not supposed to work that way. Create a link instead.

Bjeaurn avatar Jan 21 '18 16:01 Bjeaurn

@pagadalasrikanth I beliefe you have to set useHash to true so your URL will look like http://localhost:3000/#/home. Just enable it where you add the RouterModule like RouterModule.forRoot(routes, { useHash: true, preloadingStrategy: PreloadAllModules }). This way the browser won't start a request to the server (therefore reload the app) when you change the url in the browser address bar.

PascalHonegger avatar Feb 02 '18 08:02 PascalHonegger