Angular web app having extra ! in the url

183 views Asked by At

I have a basic Angular webapp running on ec2 ubuntu 16.04, using routing($routeProvider). When I open the application home page say example.com, instead of opening http://example.com/#/ it opens http://example.com/#!/ there is an extra ! which is messing up the whole url/routing structure. Not sure what I am doing wrong, Please advice.

1

There are 1 answers

1
coderdark On BEST ANSWER

Angular version 1.6 adds a "!" to $location.. check the angular page below...

https://docs.angularjs.org/guide/migration#commit-aa077e8

$location:

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 than mydomain.com/#/a/b/c the URL will become mydomain.com/#!/a/b/c.

If you actually want to have no hash-prefix, then you can restore the previous behavior by adding a configuration block to you application:

appModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);