在tutorialAngular JS教程:/index.html如何重定向到/ index#!/ phones? [查看描述]
現在,當您導航到/index.html,你將被重定向到 /index.html#!/phones和電話清單出現在瀏覽器。
它在哪裏配置,重定向/index.html
到/index.html#!/phones
?
在tutorialAngular JS教程:/index.html如何重定向到/ index#!/ phones? [查看描述]
現在,當您導航到/index.html,你將被重定向到 /index.html#!/phones和電話清單出現在瀏覽器。
它在哪裏配置,重定向/index.html
到/index.html#!/phones
?
,如果你繼續閱讀本教程,你會發現這部分配置模塊這裏大約ngRoute和興田配置文件教程會談應用/ app.config.js。
在該文件中配置路線,故有此:
angular.
module('phonecatApp').
config(['$locationProvider', '$routeProvider',
function config($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.
when('/phones', {
template: '<phone-list></phone-list>'
}).
when('/phones/:phoneId', {
template: '<phone-detail></phone-detail>'
}).
otherwise('/phones');
}
]);
你可以看到,沒有一個國家有/路徑,以便將應用這些句子否則(「/電話」),它會重定向到該網址。
請記住,如果沒有一個匹配,它會去其他地方。
如果你看一下App Config
$routeProvider. when('/phones', { template: '<phone-list></phone-list>' }). when('/phones/:phoneId', { template: '<phone-detail></phone-detail>' }). otherwise('/phones'); }
在這種情況下的情況下,當你去「/」不配置任何映射,所以它去otherwise('/phones')
;
謝謝Neetesh。 – user3290439
你必須找到負責路由的功能。看看app.config.js文件。 建議:在更大的應用程序中,好的做法是將單個文件中每個模塊的路由分開。
謝謝。我能夠弄清楚在這裏進行的路由。最初,沒有匹配,因此選擇「其他」部分;在此之後,它將匹配「when('/ phones',...」,從中選擇模板 – user3290439
是的,也就是說,最初選擇其他部分,以便它將轉到電話列表模板(/手機狀態) –