AngularJS: how to enable $locationProvider.html5Mode with deeplinking

前端 未结 5 1329
终归单人心
终归单人心 2020-11-27 12:02

When enabling the html5Mode in AngularJS via $locationProvider.html5Mode(true), navigation seems to be skewed when you land on a page deeper in the site.

<
相关标签:
5条回答
  • 2020-11-27 12:18

    Found out that there's no bug there. Just add:

    <base href="/" />
    

    to your <head />.

    0 讨论(0)
  • 2020-11-27 12:21
    1. Configure AngularJS

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

    1. Configure your server:

    https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#wiki-how-to-configure-your-server-to-work-with-html5mode

    0 讨论(0)
  • 2020-11-27 12:32

    This problem was due to the use of AngularJS 1.1.5 (which was unstable, and obviously had some bug or different implementation of the routing than it was in 1.0.7)

    turning it back to 1.0.7 solved the problem instantly.

    have tried the 1.2.0rc1 version, but have not finished testing as I had to rewrite some of the router functionality since they took it out of the core.

    anyway, this problem is fixed when using AngularJS vs 1.0.7.

    0 讨论(0)
  • 2020-11-27 12:39

    My problem solved with these :

    1- Add this to your head :

    <base href="/" />
    

    2- Use this in app.config

    $locationProvider.html5Mode(true);
    
    0 讨论(0)
  • 2020-11-27 12:41

    This was the best solution I found after more time than I care to admit. Basically, add target="_self" to each link that you need to insure a page reload.

    http://blog.panjiesw.com/posts/2013/09/angularjs-normal-links-with-html5mode/

    0 讨论(0)
提交回复
热议问题