2015-10-19 52 views
0

我正在使用angularjs,而我正在使用html5Modehtml5Mode中的Angularjs鏈接問題

在使用html5Mode之前,鏈接同時在同一頁和新標籤頁中工作。鏈接如下:

http://localhost:81/vahidnajafi/#/about

但在html5Mode,它只能在同一頁上,但是當我在新標籤中打開它,它去404 Not found頁。

http://localhost:81/vahidnajafi/about

感謝。

+0

你正在使用什麼類型的網絡服務器? – molson504x

+0

'html5Mode'是單頁面應用程序,所以它期望應用程序是一個單一的頁面。它按預期工作,並在[文檔](https://docs.angularjs.org/guide/$location)中描述。 – GillesC

+0

本質上,請確保您在快速應用中引用角度應用的主目錄: app.use(express.static(path.join(__ dirname,'app_client'))); (函數(req,res){ res.sendfile(path.join(__ dirname,'app_client','index.html')) }); 並確保您的templateUrl路由屬性以/開頭,因此它知道從根目錄引用模板的位置,而不是當前目錄。 – awimley

回答

0

您需要將請求重定向或重新路由到服務器上的根網址。

你的服務器在角度得到機會去做某件事情之前返回一個404。