I'm having trouble getting path lookup to work with a AngularJS v1.2.0 and PhoneGap/Cordova Android application. I've come pretty far with html5mode(true)
by setting <base href="."/>
in index.html and then changing $routeProvider.when('/')
to $routeProvider.when('/android_asset/www/index.html')
. After that I am able to get redirectTo('login')
to reach $routeProvider.when('/login')
and there render templateUrl: 'static/partials/login.html'
as expected.
The problem I have is that if I instead try to redirect to the login page from my Javascript code with $location.path('/login');
, the route is found but templateUrl loading fails with an insecurl
exception.
I've tried whitelisting access to file:// by using the new angular-sanitize module, but that does not help.
How can I make $location.path()
do the same things as redirectTo
so that the partial is loaded? Or is there some other way to solve this problem?
UPDATE: I got a bit forward by adding a call to replace() after the path function, e.g.:
$location.path('/login').replace();
but that seems like a hack, and it still causes the templateUrl in the otherwise route to fail with the same exception.
Any ideas on what might be wrong? Is it that html5mode(true) just does not work at this moment with Phonegap and the only way to fix this is to set it to false and add hashtags to every path (like is done in the angular phonegap seed project)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…