AngularJS 1.1.5 - automatically adding hash tag to URLs

后端 未结 3 1542
暗喜
暗喜 2020-12-29 07:16

Does anyone know why version 1.1.5 automatically adds a hashtag to your urls, and how to turn this off? IMO this is ugly looking. It happens whenever you have a url that doe

相关标签:
3条回答
  • 2020-12-29 07:39

    I experienced this issue just the other day. I solved it by enabling HTML5 mode for $locationProvider. See Docs for $location - HTML5 Mode Updated link for $location - HTML5 Mode.

    It should look similar to this:

    .config(['$locationProvider', function($locationProvider){
        $locationProvider.html5Mode(true).hashPrefix('!');
    }]);
    
    0 讨论(0)
  • 2020-12-29 07:48

    This seems to be a bug introduced in angularjs 1.1.5 (since 1.1.4 does not exhibit this problem). I have reported the bug here:

    https://github.com/angular/angular.js/issues/3083

    0 讨论(0)
  • 2020-12-29 07:49

    In $routeProvider set HTML5 mode as true as following

    $locationProvider.html5Mode(true);
    

    And in head section of your page add this following line

    <base href="/">
    
    0 讨论(0)
提交回复
热议问题