[英]Cordova + AngularJs routing not working
我們正在使用Cordova / Phonegap和AngularJs並嘗試使用路由; 路由不起作用,它不會改變視圖,並在控制台中出現以下錯誤:
無法加載有錯誤的網頁:在此服務器上找不到請求的網址。
我們的路由控制器是:
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
(/ HomeScreen / 1)的錨點不起作用。
我們嘗試過Html5模式和hashbang模式。
我們正在使用angularjs版本1.0.7。
最有可能的問題是#/讓一些瀏覽器感到困惑。 這可能有所幫助:
$locationProvider.html5Mode(true);
這將使用推送狀態來進行導航。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.