2

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 Answer 1

3

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) {
Sign up to request clarification or add additional context in comments.

1 Comment

That happens.. Np.. Glad to help you..Thanks :)

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.