2014-10-18 41 views
2

錯誤:[$注射器:模塊]由於: 錯誤:實例化模塊uiGmapgoogle地圖失敗: ng:areq]參數'fn'不是一個函數,得到了字符串AngularJS錯誤:[ng:areq]參數'fn'不是函數,得到了與谷歌地圖SDK字符串異步加載程序

我試圖在main.js(app.js)文件中添加google-maps-api到我的角度js項目,喜歡這個。不幸的是我得到了上述錯誤。我真的很感謝一些指導,我花了3個小時試圖解決這個問題,我只是無法弄清楚。我正在嘗試使用SDK Async loader而不是。

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' 
    }); 

}) 

回答

3

我今天有這個問題。我能夠通過重新安排我的html中的js refrences的順序來修復它。

我讓他們大致順序是:

<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> 

..then我的控制器和服務。

我用這個文件作爲參考 https://github.com/angular-ui/angular-google-maps/blob/master/example/example.html

希望這有助於。

相關問題