I\'m trying to make AngularJS html5 mode (true) works with Phonegap. I did a lot of search before to post this, I tried different combination of configurations, adding the
In order to get around this problem with an existing website, I add a angularjs constant at build time that indicates whether or not the build is for phonegap. At config time you can access constants and choose to apply html5mode.
//Add this portion via your build scripts e.g. grunt or gulp
//make the constant change depending on if this is a Phonegap build or not
angular.module('myAppConstants', []).constant('PhonegapConstant', true);
//How to use
angular.module('myApp', ['myAppConstants']).config(function(
$locationProvider,
PhonegapConstant
) {
if(!PhonegapConstant) {
$locationProvider.html5mode(true);
$locationProvider.hashPrefix('!');
}
});