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

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

Barbara Streisand
Release: 2024-10-24 19:42:29
Original
273 people have browsed it

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>
Copy after login

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!

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!