8

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' }); }]); 

1 Answer 1

22

You typed incorrect method name. Change

$locationProvider.html5mode(true); 

to

$locationProvider.html5Mode(true); 

with M uppercase in word mode.

Sign up to request clarification or add additional context in comments.

2 Comments

Wow! thank you so much! I knew it was something trivial but important I was missing. Frustration sometimes clouds my thinking. LOL. Thank you again!
No, problem, sometimes we just need a fresh eye!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.