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 (#) in the following way:

http://localhost:14600/app/#/quiz-detail/2

The Angular Router Module uses PathLocationStrategy by default, hence our app will do the same. Should we prefer to take the other route, we can switch to HashLocationStrategy with an override during the bootstrap phase; we will see how to do that in a short while.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.138.104