我正在构建一个AngularJS APP,并且我有第一层路由的路由工作:
ie:
/blah
/blah2
/blah3
然而,当我到达更复杂的路线时,例如:
/blah/thing
/blah2/things
/blah3/things
刷新页面时,这些路由无法正确路由。但是,当从SPA点击链接时,工作完全正常。
我正在使用以下conf运行nginx:
server {
listen 80;
root /home/app/public;
index index.html;
server_name dev-app.com;
location / {
try_files $uri $uri/ $uri.html /index.html;
}
}
以下是一些示例路线:
.when('/instances/running', {
templateUrl : 'pages/instances-running.html',
controller : 'instancesController',
currentPage : 'Running Instances',
})
.when('/instances/stopped', {
templateUrl : 'pages/instances-stopped.html',
controller : 'instancesController',
currentPage : 'Stopped Instances',
})
.when('/tickets/open', {
templateUrl : 'pages/tickets-open.html',
controller : 'ticketsController',
currentPage : 'Open Tickets',
})
请告诉我这是否是我可以解决的问题或本来就有问题的事情。
谢谢!
答案 0 :(得分:3)
必须在index.html
中添加/到src =“assets /.*”的前面 <!-- Angular && Angular Modules -->
<script src="/assets/javascript/angular.min.js"></script>
<script src="/assets/javascript/angular-datatables.min.js"></script>
<script src="/assets/javascript/angular-route.js"></script>
<script src="/assets/javascript/angular-aria.js"></script>
<script src="/assets/javascript/angular-chart.js"></script>
<script src="/assets/javascript/angular-jwt.min.js"></script>
<script src="/assets/javascript/ng-context-menu.min.js"></script>
<!-- App JS && App Modules -->
<script src="/assets/javascript/app/app.js"></script>
<script src="/assets/javascript/app/app-login.js"></script>
<script src="/assets/javascript/app/app-sessions.js"></script>
<script src="/assets/javascript/app/app-template.js"></script>
<script src="/assets/javascript/app/app-dashboard.js"></script>
<script src="/assets/javascript/app/app-account.js"></script>