2017-04-22 64 views
0

我正在使用yeoman生成器來搭配requirejs角度的web應用程序。它的工作正常,但是當我試圖通過grunt任務運行器將所有js文件連接並縮小爲單個文件時,它開始給我提供上述錯誤。我在網上研究了這個問題,常見的解決方案是我可能拼錯了任何服務注入模塊或服務不存在,我再次檢查所有的拼寫,引號等一切似乎都很好,但我仍然'無法解決這個問題。

這裏是我的app.js文件,其中我的主要模塊與依賴列出。

return angular 
.module('arteciateYeomanApp', [ 
'arteciateYeomanApp.controllers.MainCtrl', 
'arteciateYeomanApp.controllers.AboutCtrl', 
'arteciateYeomanApp.services.Xhr', 
'arteciateYeomanApp.services.Common', 
'arteciateYeomanApp.controllers.ArtworkCtrl', 
'arteciateYeomanApp.controllers.AddAccountCtrl', 
'arteciateYeomanApp.controllers.AddArtgroupCtrl', 
'arteciateYeomanApp.controllers.AddArtistCtrl', 
'arteciateYeomanApp.controllers.AddArtworkCtrl', 
'arteciateYeomanApp.controllers.AddCampaignsCtrl', 
'arteciateYeomanApp.controllers.AddGenreCtrl', 
'arteciateYeomanApp.controllers.AddInstitutionCtrl', 
'arteciateYeomanApp.controllers.AdminSignupCtrl', 
'arteciateYeomanApp.controllers.ArtistInfoCtrl', 
'arteciateYeomanApp.controllers.DirectUserSignupCtrl', 
'arteciateYeomanApp.controllers.ErrorCtrl', 
'arteciateYeomanApp.controllers.ForgotPasswordCtrl', 
'arteciateYeomanApp.controllers.GroupBuyingCtrl', 
'arteciateYeomanApp.controllers.LoginCtrl', 
'arteciateYeomanApp.controllers.AdminLoginCtrl', 
'arteciateYeomanApp.controllers.ResetPasswordCtrl', 
'arteciateYeomanApp.controllers.SignupCtrl', 
'arteciateYeomanApp.controllers.UnblockUserCtrl', 
'arteciateYeomanApp.controllers.UpdatePasswordCtrl', 
'arteciateYeomanApp.controllers.DashboardCtrl', 
'ngRoute','ngResource']).config(.....); 

這裏是我正在與縮小的js文件咕嚕任務。

註冊作業

grunt.registerTask('dev', ['requirejs' ]); 

下面是任務行書

requirejs : { 
    compile : { 
     options : { 
      baseUrl : "<%= yeoman.app %>/scripts", 
      mainConfigFile : "<%= yeoman.app %>/scripts/main.js", 
      name : "main", 
      out : "requireArterciate.js" 
     } 
    } 
} 

請讓我知道,如果我在這裏做得不對。

+0

不可能說什麼是e。錯誤消息包含調用堆棧,它可能有助於找出哪個服務導致了錯誤,但是在問題中忽略了它。問題很可能是由於應用程序未準備好縮小,因爲服務沒有正確註釋。使用https://docs.angularjs.org/guide/di#using-strict-dependency-injection – estus

回答

0

如果您需要縮小angularjs代碼,則使用以下標準格式語法來定義控制器並注入依賴關係。請參考Dependency Injection

angular.module('test').controller('testController', testController); 
testController.$inject = ['$scope', '$rootScope']; 
function testController($scope, $rootScope) {}; 
相關問題