What Is HashLocationStrategy?
To enable HashLocationStrategy in an Angular app you pass {useHash: true} when you providing routes with router module and it like this.
//Composability and Grouping
//imports used for composing modules together.
imports: [
BrowserModule,
//enableTracing enables debugging purposes only
//useHash enables the location strategy that uses the URL fragment instead of the history API.
RouterModule.forRoot(appRoots, { enableTracing: true, useHash:true })
],
The HashLocationStrategy add the route path to the hash (#) in the browser’s URL.
The hash (#) part of the URL is called the hash fragment.
When using HashLocationStrategy for routing and providing a base Href, it always placed after the hash (#) e.g.
http://localhost:8080/#/UserDetail/1
The Hash style routing using the anchor tags technique to achieve client side routing and URL never sent to the server.
The anchor tag, when used along with the hash (#) allows us to jump to a place, within apps.
The URL would look like this -
1. http://localhost:8080
2. http://localhost:8080/#/Users
3. http://localhost:8080/#/UserDetail/1
In the above URLs “#/Users” and “#/UserDetail/1” never sent to the server.
For
more detail kindly refer the link - https://www.code-sample.com/2018/05/angular-5-6-7-routing-and-navigation.html