加载模块Angular JS

时间:2015-09-23 14:10:18

标签: javascript angularjs ionic

我正在尝试仅在我有互联网连接时加载模块。问题是我不知道如何继续。我正在尝试加载的模块是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();
                }
          }

      }
      })

  })

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

在这种情况下我该如何处理?

0 个答案:

没有答案