我有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