Angular Hash vs Hashbang

Why does Angular sometimes use a hash in the URL, and in other cases use hashbang? I started writing two Angular applications from scratch. Also, HTML5 mode is not used. Both have the same default route. However, the default URLs display differently.

I have seen this random behavior for at least a year ... long before angular -route v1.6. In addition, I have always used angular -ui-router.

Default route:

configRoutes.$inject = ['$urlRouterProvider'];
function configRoutes ($urlRouterProvider) {
    $urlRouterProvider.otherwise('/');
}

Application # 1 resolves this ...    http: // localhost: 3000 ... to this ...    http: // localhost: 3000 / # /

Application # 2 resolves this ...    http: // localhost: 3001 ... to this ...    http: // localhost: 3001 / #! /

Notice the last two characters in the default URL.

I know how to activate HTML5 mode and nice urls. This is not what I am asking for. I would really like to understand the meaning of both URLs above and why Angular writes them differently.

Current versions:
angular -ui-router v0.3.2
angular v1.6.0

+4
source share
1 answer

When we upgraded from angular 1.5 to angular 1.6, the URL of our application changed from /#/to /#!/. We fixed the problem by configuring hashPrefix in the application configuration:

angular.module("myApp").config(function($locationProvider) {
   $locationProvider.hashPrefix("");  
});
+4
source

Source: https://habr.com/ru/post/1664581/


All Articles