Home  >  Article  >  Web Front-end  >  What\'s Causing the New URL Hash-Bang Prefix (!#) in Angular 1.6?

What\'s Causing the New URL Hash-Bang Prefix (!#) in Angular 1.6?

DDD
DDDOriginal
2024-10-24 14:32:02931browse

What's Causing the New URL Hash-Bang Prefix (!#) in Angular 1.6?

URL Hash-Bang Prefix (!#) in Angular 1.6

Question: Developers have noticed a change in their AngularJS project's URLs, with a hash-bang prefix (!#) being added instead of a simple hash (#). Are you experiencing something similar?

Answer:

Yes, this is a change introduced in AngularJS version 1.6. The default hash-prefix for hash-bang URLs has been updated from an empty string to an exclamation mark (!).

This change applies to applications that are not running in HTML5 mode or are using browsers that do not support it. In such cases, client-side URLs will now include the ! prefix. For instance, a URL like "mydomain.com/#/a/b/c" will now appear as "mydomain.com/#!/a/b/c."

Solution:

If you prefer to remove the hash-bang prefix, you can modify your configuration:

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

Adding this code to your configuration will revert the hash prefix to its original format.

The above is the detailed content of What\'s Causing the New URL Hash-Bang Prefix (!#) in Angular 1.6?. 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