Reputation: 2385
I use angular ui route, works fine - but in browsers that doesn't support html5mode, and it has to fall back to hashbang, links aren't working.
www.test.com/something < works
www.test.com/#/something < not working. (redirects to test.com)
not quite sure how to make the hashbanged links work ?
my desperate attempt:
if (window.history && window.history.pushState) {
// HTML5 history API is available.
$locationProvider.html5Mode({
enabled: true,
});
} else {
// hashbang mode.
window.location.hash = '/';
$locationProvider.html5Mode({
enabled: true,
});
}
$urlRouterProvider.otherwise("/");
$stateProvider
.state('statistics', {
url: "/statistics/:id",
templateUrl: '../path/statistics.html',
controller: 'ResultCtrl'
}
);
Upvotes: 0
Views: 789
Reputation: 1834
You have enabled html5mode. This mode basically means the site doesn't route with hashbang urls. I don't think you can support both.
Remove this code:
$locationProvider.html5Mode({
enabled: true,
});
https://docs.angularjs.org/guide/$location#html5-mode
According to the docs you don't need to test for push state support, it automatically falls back to hashbangs if its not supported.
Upvotes: 0
Reputation: 134
you just need to do this:
$locationProvider.html5Mode({
enabled: true,
}).hashPrefix("#");
Upvotes: 1