`[$injector:nomod] Module 'google-maps' is not available`

匆匆过客 提交于 2019-12-24 00:44:07

问题


I'm using angular-google-maps to handle google maps at an angular application. For this, I have to add the angular-google-maps.jsto the project. The page works without any error, if I add the script in the following way:

<script type="text/javascript" 
        src="http://www.directiv.es/application/html/js/nlaplante/angular-google-maps/angular-google-maps.js"></script>

But it will not work, if I use the local copy, like this:

<script type="text/javascript" 
        src="js/libs/directiv.es/angular-google-maps.js"></script>

Looking at firebug, I see the angular-google-maps.js file is loaded, but in this case, the following error occurs:

Uncaught Error: [$injector:modulerr] Failed to instantiate module mapsApp due to:
Error: [$injector:modulerr] Failed to instantiate module google-maps due to:
Error: [$injector:nomod] Module 'google-maps' is not available! You either misspelled the...<omitted>...1) 

Searching the web for hours I did not find any reason or solution. Maybe you have an idea or hint, how to find the reason?


回答1:


I found the solution and like to write down that here for the case, the someone runs into the same problem.

In my case, I downloaded the angular-google-maps extension from github, extracted that zip-file on windows an copied the file to my project. With the result, that an error occurs: Failed to instantiate module google-maps due to ... while loading "the same" js file over http everything works fine. The point is: it's not the same file!

The solution is to take the file from the URL Link and storing local:

Maybe during downloading or extracting, the zip-file was broken. Maybe there is an character problem. Whatever.

If I open that link http://www.directiv.es/application/html/js/nlaplante/angular-google-maps/angular-google-maps.js in an browser, I can right-click that file and open the source in an "source-code" editor and save that file on disk.

Now I can copy that new created file into my project folder like that location: js/libs/directiv.es/angular-google-maps.js and everything works fine.....



来源:https://stackoverflow.com/questions/22611014/injectornomod-module-google-maps-is-not-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!