3
我們正在使用Cordova/Phonegap與AngularJs並嘗試使用路由;路由不起作用,它不會改變視圖,並在控制檯中出現以下錯誤:Cordova + AngularJs路由不起作用
無法加載帶有錯誤的網頁:在此服務器上找不到請求的URL。
我們的路由控制器:
var app = angular
.module('myApp', [])
.config(function ($routeProvider, $compileProvider) {
$routeProvider.when('/', {
templateUrl: 'index.html'
}).when('/HomeScreen/:id', {
templateUrl: 'app/views/homeScreen.html'
}).otherwise({
redirectTo: '/'
});
$compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);
});
當我們改變.otherwise({ redirectTo: '/HomeScreen/1'})
它的工作原理,但隨後在index.html中的美女主播與同href
(/主屏幕/ 1)不工作。
我們嘗試過Html5模式和hashbang模式,都沒有工作。
我們使用的是angularjs版本1.0.7。
如果它不是太吵,你可以包括'index.html'的內容嗎? –
其實,如果你將'/ HomeScreen /:id'' templateUrl'改爲'views/homeScreen.html''(省略'app /''部分),它會起作用嗎? –
等一下,當'/'那麼這是你的index.html?如果index.html是一個部分,那麼主頁是什麼?在jsfiddle上發佈代碼示例? – Noogen