URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6
It is new from AngularJS 1.6, which added a new hash prefix.
Due to aa077e8, the default hash-prefix used for
$location
hash-bang
URLs has changed from the empty string (''
) to the bang ('!'
). If your
application does not use HTML5 mode or is being run on browsers that
do not support HTML5 mode, and you have not specified your own
hash-prefix then client side URLs will now contain a!
prefix. For
example, rather thanmydomain.com/#/a/b/c
the URL will become
mydomain.com/#!/a/b/c
.
Source here for more information.
If you want to remove this prefix, add this code to your config:
appModule.config(['$locationProvider', function($locationProvider) {
$locationProvider.hashPrefix('');
}]);
Why we need bang mark in hash navigation URLs?
RFC 3986 specifies that a URL fragment starts with a hash. A fragment references typically a HTML anchor. And HTML 4 defines that the ID of a HTML anchor must not contain a bang.
If you want to be sure that your tags do not collide with HTML anchors, it might be useful to mark the tags with the bang.
Meaning of the symbol ! inside URL when using ui-route angular js
It is called Fragment_identifier
The $location
service is designed to support hash prefixed URLs
for cases where the browser does not support HTML5 push-state navigation.
The Google Ajax Crawling Scheme expects that local paths within a SPA start
with a hash-bang (e.g. somedomain.com/base/path/#!/client/side/path
).
The $locationProvide
allows the application developer to configure the
hashPrefix, and it is normal to set this to a bang '!', but the default
has always been the empty string ''.
This has caused some confusion where a user is not aware of this feature
and wonders why adding a hash value to the location (e.g. $location.hash('xxx')
)
results in a double hash: ##xxx
.
This commit changes the default value of the prefix to '!', which is more
natural and expected.
See https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
Referred from
and please visit here : URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6
angular-route1.6.1 does not work correctly
Tx! I have solve it!
The reason is in version 1.6.1 the route rule has been changed.
The correct way to write the url is:
href="#!/checkout"
Annother way to sovle this problem:
app.config(['$locationProvider', function($locationProvider) {
$locationProvider.hashPrefix('');
}]);
follow:
https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52
Related Topics
React Useeffect in Depth/Use of Useeffect
Unexpected Token Colon JSON After Jquery.Ajax#Get
Es6 Variable Import Name in Node.Js
Detect Back Button Click in Browser
Ajax Jquery Refresh Div Every 5 Seconds
\U200B (Zero Width Space) Characters in My Js Code. Where Did They Come From
How to "Reset" <Div> to Its Original State After It Has Been Modified by JavaScript
Passing Variables Through Handlebars Partial
Check If File Has Changed Using HTML5 File API
HTML Anchor Link - Href and Onclick Both
Implementing Pagination in Mongodb
Why Is My Infinite Loop Blocking When It Is in an Async Function
JavaScript Tofixed Not Rounding
Can JavaScript Connect with MySQL
Removing # from Url in Angularjs While Having .Run in Routes