Reputation: 1588
I am trying to use angular's $locationProvider.html5mode() to removed the "#" in URLs, but for some reason it always throws an error that html5mode is undefined. I tried logging $locationProvider in the console to inspect its properties and html5mode is present but when I try invoking it, it throws an error that its undefined. Has anyone experience this before and wouldn't mind shedding some light on what I am missing. Thanks in advance.
var app = angular.module('app', ['appControllers', 'ngRoute']);
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5mode(true);
$routeProvider
.when('/', {
templateUrl: 'partials/home.html',
controller: 'PageController'
})
.when('/app', {
templateUrl: 'partials/app.html',
controller: 'PageController'
});
}]);
Upvotes: 8
Views: 7022
Reputation: 193301
You typed incorrect method name. Change
$locationProvider.html5mode(true);
to
$locationProvider.html5Mode(true);
with M
uppercase in word mode
.
Upvotes: 22