I'm having an issue where as long as I ad $locationProvider.html5Mode(true); to my app, it no longer follows my otherWise method defined in the routeProvider. Rather than returning the 404 page, it simply displays an error page like this:
Cannot GET /myWrongURL
app.js
angular
.module('myApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'main'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl',
controllerAs: 'about'
})
.when('/projects', {
templateUrl: 'views/projects.html',
controller: 'ProjectsCtrl',
controllerAs: 'projects'
})
.when('/contact', {
templateUrl: 'views/contact.html',
controller: 'ContactCtrl',
controllerAs: 'contact'
})
.otherwise({
redirectTo: '404.html'
});
// use the HTML5 History API
$locationProvider.html5Mode(true);
});
I used Yeoman angular templates to scaffold my app, virtually everything at this point is out of the box except the protractor tests I set up.