2016-07-15 139 views
0

我得到未捕获错误:[$ injector:modulerr]以非常奇怪的方式。角度依赖注入错误

如果我以这种方式注入依赖关系,它会抛出上述错误。

'use strict'; 
var app = angular.module('myRoutes', ['ngRoute']); 
app.config(['$routeProvider'], function ($routeProvider) { 

    }); 

但是,如果我以下面的方式翻转上面的代码片段,错误消失了。

'use strict'; 
var app = angular.module('myRoutes', ['ngRoute']); 

app.config(function ($routeProvider) { 
    //no error 
}); 

我采用了棱角分明v 1.3.1

脚本包括订单。

  • angular.js
  • 角routes.js
  • myroutes.js
  • myCtrl.js

考虑在生产环境中的微小的,我不能与第二去办法。

回答

3

您还没有闭合配置inline array annotation功能正常

app.config(['$routeProvider'], function ($routeProvider) { 

应该

//      VVVVVVVVVV removed `]` 
app.config(['$routeProvider', function ($routeProvider) { 

}]); //<-- close it here 
+0

哦。我的愚蠢的错误..感谢 –

+0

发生这种情况,谢谢:-) –