Home  >  Article  >  Web Front-end  >  Why Did Angular 1.6 Change URL Hash Prefix from # to #!?

Why Did Angular 1.6 Change URL Hash Prefix from # to #!?

Barbara Streisand
Barbara StreisandOriginal
2024-10-24 16:47:02471browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn