2016-07-15 94 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

發生這種情況,謝謝:-) –