Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling html 5 mode for Angular JS throws JS error: Failed to instantiate module due to: TypeError: Cannot read property 'html5Mode' of undefined

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

like image 652
Hoppe Avatar asked May 11 '14 15:05

Hoppe


1 Answers

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

.config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider) {
like image 143
Dalorzo Avatar answered Nov 18 '22 13:11

Dalorzo