2013-08-20 7 views
3

우리는 AngularJs와 함께 Cordova/Phonegap을 사용 중이며 라우팅을 사용하려고합니다. 라우팅이 작동하지 않고보기가 변경되지 않고 콘솔에 다음 오류가 표시됩니다.Cordova + AngularJs routing not working

오류가있는 웹 페이지를로드하지 못했습니다. 요청한 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을 사용하고 있습니다.

+0

너무 시끄럽지 않은 경우'index.html'의 내용을 포함시킬 수 있습니까? –

+0

'/ homeScreen/: id'' templateUrl'을'views/homeScreen.html'' (''app/''부분 생략)로 변경하면 실제로 작동합니까? –

+1

잠깐, '/'를 누르면 index.html이 나옵니까? index.html이 부분적인 경우 기본 페이지는 무엇입니까? jsfiddle에 코드 샘플을 게시 하시겠습니까? – Noogen

답변

0

대부분의 경우 문제는 일부 브라우저가 혼란스러워지고 있다는 것입니다. 도움이 될 수도 있습니다 :

$locationProvider.html5Mode(true); 

이렇게하면 내비게이션을 대신 수행합니다.