我有SPA,当我使用路由并想刷新页面时我得到404,因为它是客户端路由。SPA刷新页面使用路由,AngularJS
我该如何处理?
Here is my routing:
app.config(function ($routeProvider, $locationProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl: 'index.html'
})
.when('/category/gifts/', {
templateUrl: 'tpl/categories/category-gifts.html',
controller: 'giftsCtrl'
})
.when('/category/gifts/:id', {
templateUrl: 'tpl/categories/category-gifts.html',
controller: 'giftsCtrl'
})
.otherwise({ redirectTo: '/' });
$locationProvider.html5Mode(true);
});
例如:http://www.localhost 后,我进入http://www.localhost/category/gifts/并做CTRL + R或按F5键, 我得到404,我应该怎么照顾呢?
我没有任何控制器。它给了我这个: 匹配的路线不包括“控制器”路线值,这是必需的。 – IamStalker
你的应用的起点是什么? – sylwester
默认路由是'url:index.html' – IamStalker