The primary client-side routing strategy employed by Angular is the PathLocationStrategy
.
If you manually input the URL
, your server must be configured to serve the same page for all variations of requested URLs
. This approach requires collaboration from the server side.
Is there a frontend solution to address this issue?
Consider using the HashLocationStrategy
.
The HashLocationStrategy utilizes the hash fragment section of the URL to preserve client state, making it simpler to set up without necessitating cooperation from the server side. However, it might not be compatible with Angular Universal upon its release.
@NgModule({
imports: [
BrowserModule,
FormsModule,
RouterModule.forRoot(routes, { useHash: true }) //implement hashbang approach
],
Explore Location Strategies in Angular Router
Which strategy is optimal?