错误:[$injector:module] 无法实例化模块 uiGmapgoogle-maps,原因是: 错误:[ng:areq] 参数“fn”不是函数,得到字符串
我尝试将 google-maps-api 添加到 main.js (app.js) 文件中的 Angular js 项目中,现在看起来像这样。不幸的是我收到上述错误。我真的很感谢一些指导,我花了 3 个小时试图解决这个问题,但我就是不明白。我正在尝试使用 SDK 异步加载器而不是 。
angular
.module('sfeVendorApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
['google-maps'.ns()]
])
.config(['GoogleMapApiProvider'.ns()], function ($routeProvider, GoogleMapApi) {
GoogleMapApi.configure({
key: 'AIzaSyCXxlIQE_baTY18opP79TFol5Ck40xQyP8',
v: '3.17',
libraries: 'weather,geometry,visualization'
});
$routeProvider
.when('/login', {
templateUrl: 'views/login.html',
controller: 'LoginCtrl'
})
.when('/openshop', {
templateUrl: 'views/openshop.html',
controller: 'OpenShopCtrl'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl'
})
.otherwise({
redirectTo: '/login'
});
})
最佳答案
我今天也遇到了同样的问题。我可以通过重新排列 html 中 js 引用的顺序来修复它。
我大致按以下顺序排列它们:
<script src="path/bluebird.js"></script>
<script src="path/jquery.min.js"></script>
<script src="path/angular.js"></script>
<script src="path/lodash.min.js"></script>
<script src="path/angular-google-maps.js"></script>
..然后是我的 Controller 和服务。
我使用此文件作为引用 https://github.com/angular-ui/angular-google-maps/blob/master/example/example.html
希望这有帮助。
关于AngularJS 错误 : [ng:areq] Argument 'fn' is not a function, 使用 Google Maps SDK 异步加载器获取字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26437981/