2

在我的角度应用程序中,我想使用 $location.path('/'); 进行重定向 但我收到此错误未捕获错误:[$injector:modulerr] 无法实例化模块 myApp 由于:错误:[$injector:modulerr] 无法实例化模块 myApp.login 由于:TypeError:无法读取属性 'html5Mode'这里的未定义是我的代码

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

1 回答 1

3

在配置块的工厂函数中使用它之前,您错过了在 DI 数组中添加依赖项。

代码

.config(['$routeProvider', '$locationProvider', //<-- added dependency before using it in function
     function($routeProvider, $locationProvider) {
于 2015-11-29T18:47:21.117 回答