PathLocationStrategy versus HashLocationStrategy

The Angular router can be configured to follow one of two different patterns: PathLocationStrategy or HashLocationStrategy. The former is based upon the HTML5 history.pushState technique, which is by far the prefered one. It is worth noting, however, that such techniques won’t work well on older browsers, because they will automatically send a page request every time the current location.href value changes, ruining the whole SPA approach, unless the change is limited to the part of the URL that is after a hash character (#).

HashLocationStrategy is mostly a workaround that exploits such behavior, as it will instruct the router to compose all the navigation URLs prepending them with a hash character ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.