Home >Web Front-end >JS Tutorial >Why Did Angular 1.6 Change URL Hash Prefix from # to #!?
URL Hash Prefix Change from # to #! in Angular 1.6
Since the latest update to AngularJS 1.6, users have noticed a shift in URL formatting. Instead of using the previous "#/" hash prefix, AngularJS now utilizes "#!/".
What's the Reason for the Change?
The change is attributed to a new hash prefix introduced in AngularJS 1.6 (aa077e8). By default, the hash-prefix for hash-bang URLs has been modified from the empty string to an exclamation point. This applies to applications that don't employ HTML5 mode or are operating on browsers that lack HTML5 mode support. In the absence of a custom hash-prefix, client-side URLs will now incorporate the "!" prefix.
Example:
A URL like "mydomain.com/#/a/b/c" will transform into "mydomain.com/#!/a/b/c".
How to Remove the Prefix
If the "!" prefix is undesirable, it can be eliminated by adding the following code to the project configuration:
appModule.config(['$locationProvider', function($locationProvider) { $locationProvider.hashPrefix(''); }]);
For more information on this subject, refer to the referenced source material.
The above is the detailed content of Why Did Angular 1.6 Change URL Hash Prefix from # to #!?. For more information, please follow other related articles on the PHP Chinese website!