我的Angular应用程序中有一个搜索功能,当执行时会点击我的API以获取结果,然后使用$location.url
重定向用户。一切都很好......直到我尝试重新加载结果页面。当我这样做时,我收到Cannot GET /search/[search-term]
消息。
app.config.js:
'use strict';
angular.module('gameApp')
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/player/:playerId', {
templateUrl: 'player.html'
})
.when('/search/:searchTerm', {
templateUrl: '/app/gmSearchResults/gmSearchResults.html'
});
$locationProvider.html5Mode({
enabled: true,
requireBase: false,
rewriteLinks: false
});
});
相关的navbar.controller.js:
vm.getSearchResults = function(searchTerm) {
searchService.resource.getResults({
query: searchTerm
}).$promise.then(function(results) {
if (results.playerId) {
$location.url('/customer/' + results.playerId);
} else {
saveLatest(results);
$location.url('/search/' + searchTerm);
}
});
};
答案 0 :(得分:7)
设置您的快速应用:
app.route('/*').get(function(req, res) {
return res.sendFile(path.join(config.root, 'index.html'));
});
答案 1 :(得分:0)
只是对Georgii Kats答案的一个小编辑。尝试使用:
SELECT ContainerID, Master.SizeID,
Master.TypeID firstType,
Type.TypeID secondType