2
votes

in my angular application i want to make redirect with $location.path('/'); but i'm getting this error Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to instantiate module myApp.login due to: TypeError: Cannot read property 'html5Mode' of undefined here is my code

angular.module('myApp.login', ['ngRoute', 'angular-md5'])

.config(['$routeProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/login', {
templateUrl: 'login/login.html',
controller: 'loginCtrl'
});
$locationProvider.html5Mode({
  enabled: true,
  requireBase: false
}).hashPrefix('!');
}])
1

1 Answers

3
votes

You missed to add dependency in the DI array before using it in factory function of a config block.

Code

.config(['$routeProvider', '$locationProvider', //<-- added dependency before using it in function
     function($routeProvider, $locationProvider) {