I've been using the "standard" routes in Angular 1 that use the
#
/app#/home
/app/home
$locationProvider.html5Mode(true)
/app#/home
/app/home
$routeProvider
.when({ ... })
.otherwise({
'controller': function($location) {
var hash = $location.hash();
// At this point the hash is undefined (even when there is one in the URL)
console.log('hash = ' + hash);
// if (hash && hash.indexOf('/') == 0) {
// $location.path(hash);
// } else {
// $location.path('/home')
// }
}
});
Use $routeChangeStart :
angular.module('routing', ['ngRoute'])
.run(['$rootScope', '$location', '$window', function($rootScope, $location, $window) {
$rootScope.$on("$routeChangeStart",
(event, current, previous, rejection) => {
if (/#\//.test($window.location.hash)) {
$location.path($window.location.hash.replace('#', ''));
}
});
...