2014-12-03 26 views
3

我在我的Angular應用程序中使用了angular-xeditable。它工作正常發展的環境,但在生產中,當所有的JS文件縮小,我得到這個錯誤:

Uncaught Error: [$injector:strictdi] http://errors.angularjs.org/1.3.5/$injector/strictdi?p0=function(n) 

搜索我的代碼,我發現,出問題時xeditable。在這裏,在coffescript應用程序創建代碼:

# create the angular app 
angular.module 'dbManagerApp', ['xeditable', 'ngDraggable'] 


# set the theme for the xeditable 
.run (editableOptions, editableThemes) -> 

    # set the default theme 
    editableOptions.theme = 'default' 

    # override the ok button 
    editableThemes['default'].submitTpl = '<div class="small primary btn"><input type="submit" value="Ok" /></div>' 

    # override the cancel button 
    editableThemes['default'].cancelTpl = '<div class="small warning btn" ng-click="$form.$cancel()"><a href="#">Cancel</a></div>' 

而且這裏的縮小版本:

(function(){angular.module("dbManagerApp",["xeditable","ngDraggable"]).run(function(n,t){if(!_.isUndefined(n||_.isUndefined(n.theme)))return n.theme="default",t["default"].submitTpl='<div class="small primary btn"><input type="submit" value="Ok" /><\/div>',t["default"].cancelTpl='<div class="small warning btn" ng-click="$form.$cancel()"><a href="#">Cancel<\/a><\/div>'})}).call(this); 
//# sourceMappingURL=DbManagerApp.min.js.map 

如果我評論的run方法裏面的代碼,它不會拋出異常。該方法用於配置documentation中描述的xeditable。 我無法弄清楚這種奇怪的行爲,有沒有辦法看到xeditable是否被成功添加到角度應用程序或者有沒有其他的東西來檢查?

回答

6

你要注入的依賴關係:

.run (['editableOptions', 'editableThemes', function(editableOptions, editableThemes) 

同樣給控制器,服務等(還記得運行的)前一個]添加到

這是由於這樣的事實:如上所述,縮小的代碼將是:

.run(['editableOptions', 'editableThemes', function(n,t){ 

nt將是對這些依賴關係的引用。