Javascript 加载模块

Javascript 加载模块,javascript,angularjs,ionic,Javascript,Angularjs,Ionic,我正在尝试仅在有internet连接时加载模块。问题是我不知道如何进行。我试图加载的模块是ngMap,下面是我正在使用的代码,但它不起作用: angular.module('starter', ['ionic','ngCordova','starter.getters','starter.main','starter.intro']) .run(function($ionicPlatform,$ionicPopup) { $ionicPlatform.ready(function() {

我正在尝试仅在有internet连接时加载模块。问题是我不知道如何进行。我试图加载的模块是ngMap,下面是我正在使用的代码,但它不起作用:

angular.module('starter', ['ionic','ngCordova','starter.getters','starter.main','starter.intro'])

.run(function($ionicPlatform,$ionicPopup) {
   $ionicPlatform.ready(function() {
      if(window.Connection) {
                if(navigator.connection.type == Connection.NONE) {
                    $ionicPopup.confirm({
                        title: "Ligação à internet",
                        content: "Por favor ligue-se a internet para fazer uso de todas as funcionalidades."
                    })
                    .then(function(result) {
                        if(!result) {
                            ionic.Platform.exitApp();
                        }
                    });
                }
          else
          {
              //the module I'm trying to load when I do have internet
               angular.module('starter', ['ngMap']);

                // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
                // for form inputs)
                if(window.cordova && window.cordova.plugins.Keyboard) {
                  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
                }
                if(window.StatusBar) {
                  // org.apache.cordova.statusbar required
                  StatusBar.styleDefault();
                }
          }

      }
      })

  })
我尝试在主模块声明中加载模块,但它给了我一个错误,说它无法加载模块


在这种情况下,我如何继续?

我不确定有条件地加载模块是否可行。始终加载模块,但仅在您可以访问internet的情况下在控制器中使用。您是否有
script
标记来拉入ngMap javascript文件?@christory问题是,如果我每次加载模块,就会出现以下错误:ncaught error:[$injector:modulerr]无法实例化模块启动器,原因是:错误:[$injector:modulerr]未能实例化模块ngMap,原因是:错误:[$injector:nomod]模块“ngMap”不可用!您可能拼错了模块名称或忘记加载它。我不知道如何规避此问题…如果您试图制作一个不能始终访问internet的应用程序,则不应使用CDN或在运行时从internet下载脚本。您应下载包或脚本并将其放置在我的位置n你的应用程序就是这样。简单到如果你想让scritp文件离线,然后下载并放在ionic lib文件夹中。我不确定有条件地加载模块是否可行。一直加载模块,但只有在你可以访问internet的情况下才在你的控制器中使用它。你是否有
脚本
标签来拉入ngMap javascript文件?@christory问题是,如果我每次加载模块,就会出现以下错误:ncaught错误:[$injector:modulerr]未能实例化模块启动器,原因是:错误:[$injector:modulerr]未能实例化模块ngMap,原因是:错误:[$injector:nomod]模块“ngMap”不可用!您可能拼错了模块名称或忘记加载它。我不知道如何规避此问题…如果您试图制作一个不能始终访问internet的应用程序,则不应使用CDN或在运行时从internet下载脚本。您应下载包或脚本并将其放置在我的位置如果你想让scritp文件离线,那么就下载并放到ionic lib文件夹中。