Encountering a unique issue while using html5Mode
with ngRoute. Here is the relevant snippet of code:
(function () {
var config = function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'home/home.view.html',
controller: 'homeCtrl',
controllerAs: 'vm'
})
.when('/about', {
templateUrl: 'common/views/genericText.view.html',
controller: 'aboutCtrl',
controllerAs: 'vm'
})
.when('/location/:locationId', {
templateUrl: 'locationDetail/locationDetail.view.html',
controller: 'locationDetailCtrl',
controllerAs: 'vm'
})
.otherwise({redirectTo: '/'});
/* $locationProvider.html5Mode({
enabled: true,
requireBase: false
}); */
};
angular
.module('loc8r', ['ngRoute', 'ngSanitize'])
.config(['$routeProvider', '$locationProvider', config]);
})();
The problem arises specifically with the route for /location/:locationId
. When html5Mode
is enabled, loading a URL like
http://127.0.0.1:3000/location/5a27ab691c5e0a989c0634da
results in a blank page. Node logging indicates that both template and controller are accessed. Surprisingly, changing the route from /location/:locationId
to just /:locationId
allows the page to load with a URL like http://127.0.0.1:3000/5a27ab691c5e0a989c0634da
. Yet, to make /location/:locationId
work, html5Mode needs to be disabled and access the URL as http://127.0.0.1:3000/#!/location/5a27ab691c5e0a989c0634da
. How can I resolve this issue and get html5Mode
functioning correctly?
If needed, I can upload all recent changes to GitHub for a full code review.