将谷歌地图包含在我的模块中会引发错误

时间:2014-08-19 05:22:53

标签: angularjs angular-google-maps

我正在尝试将google-maps添加到我的模块中,但我遇到了这个问题 - 错误:[$ injector:unpr]以及类似的结尾 -

angular.module("app", ["google-maps"])
angular.module("app.controllers", ["ngCookies"]).controller("AppCtrl", ["$scope", "$location", "$cookies",
    function($scope, $location, $cookies) {
        return $scope.isSpecificPage = function() {
        }, $scope.main = {
           }
        }
    }]).controller("DashboardCtrl", ["$scope", "$cookies", "$location", "google-maps",  
        function($scope, $cookies, $location) {
            return $scope.map = {
    center: {
        latitude: 45,
        longitude: -73
    },
    zoom: 8
};
    }])

我遵循这个,就像把文件放在同一个顺序 - https://angular-ui.github.io/angular-google-maps/#!/use但我遇到了问题。有人可以回复此事。

1 个答案:

答案 0 :(得分:1)

在控制器google-maps

中看起来没有正确包含DashboardCtrl依赖项
controller("DashboardCtrl", ["$scope", "$cookies", "$location", "google-maps",  
        function($scope, $cookies, $location) {

请你删除依赖

controller("DashboardCtrl", ["$scope", "$cookies", "$location",  
        function($scope, $cookies, $location) {