Loading Modules

Hello to everyone,
I’m trying to load a module only when I have an internet connection. The problem is that I dont know how to proceed. The module that I’m trying to load is the ngMap, and here is the code that I am using, but it is not working:

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) {
                        title: "Ligação à internet",
                        content: "Por favor ligue-se a internet para fazer uso de todas as funcionalidades."
                    .then(function(result) {
                        if(!result) {
              //the module I'm trying to load 
               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) {
                if(window.StatusBar) {
                  // org.apache.cordova.statusbar required

I tried loading the module in the main module declaration, but it gave me an error saying that it was unable to load the module.

How can I proceed in this case?

Why do you want to load the module in case of internet connection?
If you don’t have internet connection you wont be able to access the google.maps object anyway so you wouldn’t use it. If you’re trying to save space or memory or something, you’re already including the scripts in the index.html file and you’re unnecessarily complicating your app.

But I found this link about injecting modules: http://stackoverflow.com/questions/27687059/inject-modules-conditionally-in-angularjs-app

You probably solved this problem already, but I was just wondering why you wanted to do that.