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>
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!