Home  >  Article  >  Web Front-end  >  How to Remove the Angular 1.6 URL Hash-Bang Prefix (#!/)?

How to Remove the Angular 1.6 URL Hash-Bang Prefix (#!/)?

Barbara Streisand
Barbara StreisandOriginal
2024-10-24 19:42:29277browse

How to Remove the Angular 1.6 URL Hash-Bang Prefix (#!/)?

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

This issue occurs due to an update introduced in AngularJS 1.6, which added a new default hash prefix. Previously, the prefix was an empty string ('') for $location hash-bang URLs, but it has now been changed to the exclamation mark ('!').

If you haven't configured your own hash prefix and your application runs in browsers that don't support HTML5 mode, URLs will now include the '!' prefix. For instance, instead of "mydomain.com/#/a/b/c," the URL will look like "mydomain.com/#!/a/b/c."

Solution:

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

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

The above is the detailed content of How to Remove the Angular 1.6 URL Hash-Bang Prefix (#!/)?. 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