2014-09-02 69 views
0

我想包括這個angularjs庫AngularGeo 到我的項目地理庫,但我得到的app.js文件angularjs模塊的這個錯誤:負載angularjs與requirejs

Failed to instantiate module myApp due to: 
Error: [$injector:unpr] Unknown provider: angular-geo 

我看到angularjs,地理文件被加載,我看到他們在開發工具,但無論如何,我得到這個問題。

main.js

require.config({ 
    baseUrl: 'app', 
    //urlArgs: 'v=1.0' 
    paths: { 
     'angular': '../scripts/angular', 
     'angular.route': '../scripts/angular-route', 
     'angular.localStorage': '../scripts/angular-local-storage.min', 
     'lodash': '../scripts/lodash', 
     'angular-google-maps': '../scripts/angular-google-maps', 
     'jquery': '../scripts/jquery-2.1.1', 
     'uiBootstrap': '../scripts/ui-bootstrap-0.11.0.min', 
     'underscore': '../scripts/underscore-min', 
     'gmaps': '../scripts/gmaps', 
     'async': '../scripts/requirejs-plugins/async', 
     'propertyParser': '../scripts/requirejs-plugins/propertyParser', 
     'goog': '../scripts/requirejs-plugins/goog', 
     'select2': '../scripts/select2/select2', 
     'ui-select2': '../scripts/ui-select2/src/select2', 
     'angular-detour': '../scripts/angular-detour/dist/angular-detour.amd', 
     'angular-geo': '../scripts/modules/angularGeo/angulargeo', 
     'angular-geo-providers.google': '../scripts/modules/angularGeo/providers/angulargeo-google' 
    }, 

    shim: { 
     'angular': { 
      exports: 'angular', 
      deps: ['jquery'] 
     }, 
     'underscore': { 
      exports: '_' 
     }, 
     'angular.route': ['angular'], 
     'angular.localStorage': ['angular'], 

     'angular-google-maps': { 
      deps: ['angular', 'underscore'], 
      exports: 'angular-google-maps' 
     }, 
     'uiBootstrap': ['angular'], 
     'select2': ['jquery', 'angular'], 
     'ui-select2': ['select2'], 
     'angular-geo': { 
      exports: 'angular-geo', 
      deps: ['angular', 'goog'] 
     }, 
     'angular-geo-providers.google': { 
      exports: 'angular', 
      deps: ['angular', 'angular-geo'] 
     } 
    } 
}); 

app.js

define(['angular', 'angular.route', 'angular.localStorage', 'uiBootstrap', 'angular-google-maps', 'services/routeResolver', 'ui-select2', 'angular-detour', 'angular-geo'], function() { 
    var app = angular.module('myapp', ['ngRoute', 'LocalStorageModule', 'ui.bootstrap', 'google-maps', 'routeResolverServices', 'ui.select2', 'agt.detour', 'angular-geo']); 
    app.config(['$routeProvider', 'routeResolverProvider', '$controllerProvider', '$compileProvider', '$filterProvider', '$provide', '$locationProvider', 'angular-geo', function ($routeProvider, routeResolverProvider, $controllerProvider, $compileProvider, $filterProvider, $provide, $locationProvider, angularGeoProvider, angularGeoGoogleProvider) { 
     angularGeoProvider.addProvider(angularGeoGoogleProvider.name); 
    } 
} 

回答

0

依賴性的名稱(不模塊依賴)應angularGeo。由於您可能需要供應商,angularGeoProvider - 而不是angular-geo。此外,由於您也在使用angularGeoGoogleProvider,因此也將其添加到依存關係列表中,即:

define(['angular', ..., 'angular-geo'], function() { 
    var app = angular.module('myapp', ['ngRoute', ..., 'angular-geo']); 
    app.config([ 
     '$routeProvider', ..., 'angularGeoProvider', 'angularGeoGoogleProvider', 
     function ($routeProvider, ..., angularGeoProvider, angularGeoGoogleProvider) { 
      angularGeoProvider.addProvider(angularGeoGoogleProvider.name); 
     } 
    ]); 
};