我正在使用angularjs ngRoute来路由单个页面应用程序。它显示了localhost/about或localhost/blog。 当我reaload,“无法GET/about”。我怎样才能解决这个问题。在ngRoute中刷新页面时找不到页面
我的路由器配置如下。
var myApp = angular.module('myApp',['ngRoute']);
myApp.config(['$locationProvider','$routeProvider',function($locationProvider,$routeProvider){
$locationProvider.html5Mode(true);
$routeProvider
.when('/',{
templateUrl: 'views/pages/home.html',
controller: 'homeCtrl'
})
.when('/about',{
templateUrl: 'views/pages/about.html',
controller: 'aboutCtrl'
})
.when('/contact',{
templateUrl: 'views/pages/contact.html',
controller: 'contactCtrl'
})
.when('/blog',{
templateUrl: 'views/pages/blog.html',
controller: 'blogCtrl'
})
.otherwise({redirectTo: '/home'});
}]);
我只使用角度。
您的后端需要捕获所有请求并为您的Angular应用程序提供服务。 – str
正如你所说的“我只使用角度”,那么你能提供一个JSFiddel或Plunker的例子,你的代码不工作? –