8

How can I enable html 5 mode for Angular JS?

'use strict'

var blogApp = angular.module('blogApp', ['ngRoute'])
    .config(['$routeProvider', function ($routeProvider, $locationProvider) {
    $routeProvider.when('/disclaimer', { templateUrl: 'templates/disclaimer.html', controller:         'DisclaimerCtrl' });
    $routeProvider.otherwise({ redirectTo: '/' });
    $locationProvider.html5Mode(true);
}]);

When I add the line about html5mode, I get the following JS error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to:

TypeError: Cannot read property 'html5Mode' of undefined

I'm using Angular 1.2.15 on IIS

1
  • $locationProvider is not declared in injections list (in config(), before function declaration). Commented May 11, 2014 at 15:31

1 Answer 1

20

config(['$routeProvider', is missing $locationProvider declaration on the array.

.config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider) {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.