2017-01-30 34 views
0

我正在學習使用Google Maps集成創建MEAN堆棧項目的教程。我沒有任何問題完成了項目,因此我停止了這個項目。當我回來檢查時,它不再工作。我沒有改變任何代碼。我甚至從我的存儲庫中提取了以前的工作提交,但是出現錯誤

[$injector:modulerr] http://errors.angularjs.org/1.2.25/$injector/modulerr?p0=scotchApp&p1=Error…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.25%2Fangular.min.js%3A18%3A387) 

仍然存在。我真的不知道出了什麼問題,因爲這以前工作正常。我希望有人能幫忙。

編輯。這是我的項目的'gservice'服務的一部分。

// Creates the gservice factory. 
// This will be the primary means by which we interact with Google Maps 
angular.module('gservice', []) 
    .factory('gservice', function($rootScope, $http) { 
+0

在此處發佈代碼 – Sajeetharan

+0

通常,AngularJS中的那種錯誤是由源代碼縮小或uglification引起的。你使用的是webpack,gulp還是Rails? – IzumiSy

+0

@IzumiSy,不,我不是。 :) – cryoheart

回答

1

的問題是在這裏:components.html

<!-- Client Scripts --> 
<script src="../app/client/routes/script.js"></script> 
<script src="../app/client/service/gservice.js"></script> 
<script src="../app/client/service/aservice.js"></script> 

scotchApp模塊在script.js定義爲:

var scotchApp = angular.module('scotchApp', ['ngRoute', 
    'ngCookies', 
    'controllerStoreDetail', 'controllerStoreCategory', 
    'controllerStoreQuery', 'controllerUserDetail', 
    'controllerUserAuthentication', 'geolocation', 
    'gservice', 'aservice', 
    'datatables' 
]); 

它有gservice依賴,aservice等,但這些文件在script.js之後加載。所以,當加載你的模塊(script.js)時,角度無法找到這些服務的定義。您需要確保在script.js之前加載所有依賴項。

@devqon曾問過這個問題:

Is your js file which declares the gservice module included before the js file which declares the scotchApp module?

要你回答:

@devqon Yes it is. I really find this case weird as it was really working perfectly for weeks until now.

似乎哪個不是如此。

糾正您加載JS文件的順序,錯誤將消失。

+0

錯誤仍然存​​在。我已經完成了你所說的話,我只是沒有將修改推向回購協議。 – cryoheart

+0

在這種情況下,我想人們會真的需要*看到*在您的網站上發生的錯誤,以便他們可以調試和幫助您。 https://stackoverflow.com/help/mcve –

+0

您可以從我給您的存儲庫運行該項目。 – cryoheart

0

我修復了這個問題。原因是加載Google Maps API腳本的src中缺少「v = 3」。由於該項目以前工作正常,我仍然不這樣做。

相關問題