所以,我對AngularJS來說很新,我正嘗試在我的應用程序中使用AngularJs ngRoute。當url輸入時AngularJS路由不起作用
它所有的工作順利,當我開始在應用主頁:
http://localhost:8080/appName/
當我點擊從這點鏈接它工作的順利進行。
但是,當我輸入一個我知道存在/作品的URL時,它給了我一個404錯誤。如果我通過使用應用程序而不是url加載該鏈接,即使它具有相同的url。
Eg. http://localhost:8080/appName/search
將給出404,即使這是默認重定向的相同url。
的確,通過在該位置鍵入來加載的唯一url是我上面提到的基本URL。
我app.js看起來是這樣的:
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){
$routeProvider
.when("/search", {
templateUrl: "search.html",
controller: "SearchController"
})
.when("/results", {
templateUrl: "results.html",
controller: "ResultsController"
})
.when("/browse", {
templateUrl: "browse.html",
controller: "BrowseController"
})
.otherwise({redirectTo:"/search"});
//This gets rid of the # on the urls to the templates
$locationProvider.html5Mode(true);
}]);
我一個glassfish4服務器上託管這一點。
有什麼明顯的我失蹤/誤解有關ngRoute如何工作?是否有一些我缺少的設置?
所有幫助表示讚賞...
編輯1:作爲@Matthew格林下面說,我需要配置Web服務器返回的index.html所有網頁下方
http://localhost:8080/appName
我知道我在這裏完全密集,但這裏配置的是什麼?我將代碼放在MAVEN Jersey-Quickstart-Webapp中。
我想我們需要更多的信息 - 至少是$ routeProvider配置和你正在使用的特定的URL。 – Beartums
也許它會幫助你:http://stackoverflow.com/questions/22739455/htaccess-redirect-for-angular-routes –
我已經更新了問題,以顯示基本的$ routeProvider設置,以及有問題的網址 –