【发布时间】:2014-10-17 12:46:29
【问题描述】:
我正在尝试在我的应用中使用 angular google maps 指令,但我不断收到“未定义错误”
这是我的 app.js
angular.module('app', ['cs'])
.config(['GoogleMapApiProvider'.ns(), function (GoogleMapApi) {
GoogleMapApi.configure({
// key: 'your api key',
v: '3.17',
libraries: 'weather,geometry,visualization'
});
}])
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
//routes
}])
和我的控制器
angular.module('cs.Controllers')
.controller('MapController', ['$rootScope', '$scope', '$window', '$document', 'MenuService', 'GoogleMapApi'.ns(),
function($rootScope, $scope, $window, $document, menuService, GoogleMapApi) {
$rootScope.menuList = menuService.all();
}]);
可能是什么问题
【问题讨论】:
-
'GoogleMapApiProvider'是一个字符串。'GoogleMapApiProvider'.ns()调用字符串的ns方法。我从未听说过内置的ns方法,所以我猜您正在使用的某个库应该添加该方法(AngularJS 不会添加它),对吧?这对我来说毫无意义,但你是编写代码的人。 -
@SergiuParaschiv 代码来自网站上的文档angular-ui.github.io/angular-google-maps/#!/api
-
你为什么要用两个.config()
标签: javascript angularjs google-maps-api-3