$location / switching between html5 and hashbang mode / link rewriting

前端 未结 4 1617
情深已故
情深已故 2020-11-22 01:49

I was under the impression that Angular would rewrite URLs that appear in href attributes of anchor tags within tempaltes, such that they would work whether in html5 mode or

4条回答
  •  臣服心动
    2020-11-22 02:32

    Fur future readers, if you are using Angular 1.6, you also need to change the hashPrefix:

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

    Don't forget to set the base in your HTML :

    
        
        ...
    
    

    More info about the changelog here.

提交回复
热议问题