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

Why Did the Default Hash Prefix Change in AngularJS 1.6?

Linda Hamilton
Release: 2024-10-24 17:52:02
Original
485 people have browsed it

Why Did the Default Hash Prefix Change in AngularJS 1.6?

Understanding the AngularJS URL Hash-Bang Prefix in Version 1.6

Upon returning to an AngularJS project, you may notice that your URLs have transitioned from using the hash prefix "#" to "#!/". Why has this change occurred?

New Hash Prefix with AngularJS 1.6

AngularJS 1.6 introduced a substantial change by updating the default hash prefix for URLs that utilize the hash-bang ($location.hashbang) URL format. This prefix now defaults to "!" instead of being an empty string. As a result, URLs that are not operating in HTML5 mode or on browsers without HTML5 support will exhibit the "!" prefix.

For instance, instead of "mydomain.com/#/a/b/c," the URL will display as "mydomain.com/#!/a/b/c."

Customizing the Hash Prefix

If you prefer the previous URL format without the "!" prefix, you can override the default setting in your application's configuration:

<code class="javascript">appModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);</code>
Copy after login

By adding this code, the hash-bang prefix will be removed from your URLs, reverting them to the "hash" notation (#) format.

The above is the detailed content of Why Did the Default Hash Prefix Change in AngularJS 1.6?. 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!