Home  >  Article  >  Web Front-end  >  Why Did AngularJS 1.6 Change Hash Prefixes from \"/admin#\" to \"/admin#!/\"?

Why Did AngularJS 1.6 Change Hash Prefixes from \"/admin#\" to \"/admin#!/\"?

Linda Hamilton
Linda HamiltonOriginal
2024-10-24 18:47:35262browse

Why Did AngularJS 1.6 Change Hash Prefixes from

Angular 1.6 Introduces Hash-Bang Prefix (#!/) in URLs

Q: Why did my AngularJS app's URLs change from "/admin#/” to "/admin#!/"?

Since AngularJS 1.6, a new hash prefix has been added to URLs.

According to the documentation:

Due to aa077e8, the default hash-prefix used for $location hash-bang URLs has changed from the empty string ('') to the bang ('!').

Q: Why the change?

The hash prefix is used to differentiate AngularJS hash-bang URLs from other hash values in the URL. This helps prevent conflicts and ensures correct operation.

Q: How can I revert to the old behavior?

To remove the hash-bang prefix, add the following code to your AngularJS module configuration:

appModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);

The above is the detailed content of Why Did AngularJS 1.6 Change Hash Prefixes from \"/admin#\" to \"/admin#!/\"?. 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