NG.V · Angular 22 practice question
Which statement correctly describes the primary difference between using the default path location strategy in Angular routing (which generally uses the path-based approach) versus explicitly enabling the hash location strategy?
Check answer and explanation
Correct answer: Hash location utilizes the URL fragment identifier (`#`) to manage state, allowing the application to work correctly even when the root path is not configured on the web server, whereas path location relies on server configuration for clean URLs.
Explanation
The path location strategy (`/home`) relies on the server being configured to map all unknown routes back to the main `index.html` file (a fallback mechanism). The hash location strategy (`/#/home`) includes the routing information within the hash (`#`), meaning the browser handles the view change locally, making it more robust when the server setup cannot be customized to handle clean paths.
Common trap
Options A and B confuse which mechanism uses which part of the URL structure. Option D is incorrect as both support dynamic routing.
Source: Angular Router Guide - Routing (https://angular.dev/guide/routing)
Checked against the cited text on 2026-11-27.