我有兩個HTML文件 - 在一維的思想,其中index.html
作爲主頁,app-route
作爲主路由器>index.html
和start.html
AngularJS:在單個應用程序中是否可以使用兩個不同的路由器(每個.html一個)加載兩個不同的html?
到目前爲止,我正在開發一個應用程序(小應用程序)應用程序。現在我們正在創建一個更大的應用程序,如.com
網站,並將以前的應用程序與此集成在一起(.com
)。
我們不想打擾較小的應用程序代碼,我們正在開發一個.com網站,它是一個不同的html(start.html
)和一個不同的路由器(dot-com-route.js
)。現在,無論何時我嘗試加載http://localhost/myApp/app/#/start.html,它都會通過app-route.js加載index.html?
它總是像角度應用程序尋找index.html
文件來執行?
這是我的應用程序,route.js:
smartPrintApp.config(['$routeProvider','$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'pages/smart_print_landing/smart-print-landing.html'
}).
when('/index.html', {
templateUrl: 'pages/smart_print_landing/smart-print-landing.html'
})
}
]);
我相信你已經在路由中加入了角碼('when('/')')它使用'index.html'。你能發佈你的JS代碼嗎? – Vucko
@vucko我已經爲你更新了app-route.js – FlashyFuddyFuddy
當你點擊你的http://localhost/myApp/app/#/start.html瀏覽器時會加載一些HTML(取決於你的後端),這應該是你的index.html然後角將檢查散列,並將加載您在templateUrl中指定的模板,並將它注入到任何具有ng-view屬性的index.html中。如果你想讓start.html代替index.html,那麼你需要在服務器上改變它。對不起,如果我不明白你想要什麼 – Molda