Removing # from url in Angularjs while having .run in routes

后端 未结 7 610
感情败类
感情败类 2020-11-27 07:02

Here is my app.js route file in AngularJS

var app = angular.module(\'myApp\', [\'ngRoute\', \'ngAnimate\', \'toaster\']);
app.config([\'$routeP         


        
相关标签:
7条回答
  • 2020-11-27 07:42

    Are you by chance receiving a 404 error ? Whenever you change the mode to html5history you have to tell the web server to always return the index page no matter what URL is requested. As the angular docs says here: https://docs.angularjs.org/guide/$location

    Using this mode requires URL rewriting on server side, basically you have to rewrite all your links to entry point of your application (e.g. index.html). Requiring a <base> tag is also important for this case, as it allows Angular to differentiate between the part of the url that is the application base and the path that should be handled by the application.

    Have you tried doing that and configured it properly ? Also remember that you have to specify the base entry href of your application for it to work like

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