Removing the fragment identifier from AngularJS urls (# symbol)

后端 未结 14 2043
Happy的楠姐
Happy的楠姐 2020-11-22 00:01

Is it possible to remove the # symbol from angular.js URLs?

I still want to be able to use the browser\'s back button, etc, when I change the view and will update th

14条回答
  •  旧时难觅i
    2020-11-22 00:54

    Step 1: Inject the $locationProvider service into the app config's constructor

    Step 2: Add code line $locationProvider.html5Mode(true) to the app config's constructor.

    Step 3: in the container (landing, master, or layout) page, add html tag such as inside the tag.

    Step 4: remove all '#" for routing config from all anchor tags. For examples, href="#home" becomes href="home"; href="#about" becomes herf="about"; href="#contact" becomes href="contact"

     
    

提交回复
热议问题