Home > Web Front-end > JS Tutorial > body text

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

Barbara Streisand
Release: 2024-10-24 16:47:02
Original
470 people have browsed it

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('');
}]);
Copy after login

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!

source:php
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!