我正在使用 angular-google-maps 在 Angular 应用程序中处理 google map 。为此,我必须将 angular-google-maps.js
添加到项目中。
如果我按以下方式添加脚本,该页面可以正常工作,不会出现任何错误:
<script type="text/javascript"
src="http://www.directiv.es/application/html/js/nlaplante/angular-google-maps/angular-google-maps.js"></script>
但是如果我使用本地副本,它将不起作用,如下所示:
<script type="text/javascript"
src="js/libs/directiv.es/angular-google-maps.js"></script>
查看 firebug,我看到 angular-google-maps.js
文件已加载,但在这种情况下,会出现以下错误:
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)
在网上搜索了几个小时,我没有找到任何原因或解决方案。也许您有一个想法或提示,如何找到原因?
最佳答案
我找到了解决方案,并想在这里写下这个案例,有人遇到了同样的问题。
就我而言,我从 github 下载了 angular-google-maps 扩展,在 Windows 上提取该 zip 文件,然后将该文件复制到我的项目中。结果,出现错误:由于...而无法实例化模块 google-maps
,同时通过 http 加载“相同”js 文件一切正常。重点是:这不是同一个文件!
解决方案是从 URL 链接中获取文件并存储在本地:
也许在下载或解压过程中,zip 文件已损坏。也许性格有问题。无论如何。
如果我在浏览器中打开该链接http://www.directiv.es/application/html/js/nlaplante/angular-google-maps/angular-google-maps.js
,我可以右键单击该文件并在“源代码”编辑器中打开源代码并将该文件保存在磁盘上。
现在我可以将新创建的文件复制到我的项目文件夹中,例如该位置:js/libs/directiv.es/angular-google-maps.js
,一切正常......
关于javascript - `[$injector:nomod] Module ' 谷歌地图 ' is not available`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22611014/