dist/angularAMD.js
function setAlternateAngular() {
        // This method cannot be called more than once
        if (alt_angular) {
            throw new Error('setAlternateAngular can only be called once.');
        } else {
            alt_angular = {};
        }

        // Make sure that bootstrap has been called
        checkBootstrapped();

        // Create a a copy of orig_angular with on demand loading capability
        orig_angular.extend(alt_angular, orig_angular);

        // Custom version of angular.module used as cache
        alt_angular.module = function (name, requires) {
            if (typeof requires === 'undefined') {
                // Return module from alternate_modules if it was created using the alt_angular
                if (alternate_modules_tracker.hasOwnProperty(name)) {
                    return alternate_modules[name];
                } else {
                    return orig_angular.module(name);
                }
            } else {
                var orig_mod = orig_angular.module.apply(null, arguments),
                    item = { name: name, module: orig_mod};
                alternate_queue.push(item);
                orig_angular.extend(orig_mod, onDemandLoader);
                
                /*
                Use `alternate_modules_tracker` to track which module has been created by alt_angular
                but use `alternate_modules` to cache the module created.  This is to simplify the
                removal of cached modules after .processQueue.
                */
                alternate_modules_tracker[name] = true;
                alternate_modules[name] = orig_mod;
                
                // Return created module
                return orig_mod;
            }
        };
                
        window.angular = alt_angular;

        if (require.defined('angular')) {
            require.undef('angular');
            define('angular', [], alt_angular);
        }
    }
function setAlternateAngular() {
        // This method cannot be called more than once
        if (alt_angular) {
            throw new Error('setAlternateAngular can only be called once.');
        } else {
            alt_angular = {};
        }

        // Make sure that bootstrap has been called
        checkBootstrapped();

        // Create a a copy of orig_angular with on demand loading capability
        orig_angular.extend(alt_angular, orig_angular);

        // Custom version of angular.module used as cache
        alt_angular.module = function (name, requires) {
            if (typeof requires === 'undefined') {
                // Return module from alternate_modules if it was created using the alt_angular
                if (alternate_modules_tracker.hasOwnProperty(name)) {
                    return alternate_modules[name];
                } else {
                    return orig_angular.module(name);
                }
            } else {
                var orig_mod = orig_angular.module.apply(null, arguments),
                    item = { name: name, module: orig_mod};
                alternate_queue.push(item);
                orig_angular.extend(orig_mod, onDemandLoader);
                
                /*
                Use `alternate_modules_tracker` to track which module has been created by alt_angular
                but use `alternate_modules` to cache the module created.  This is to simplify the
                removal of cached modules after .processQueue.
                */
                alternate_modules_tracker[name] = true;
                alternate_modules[name] = orig_mod;
                
                // Return created module
                return orig_mod;
            }
        };
                
        window.angular = alt_angular;

        if (require.defined('angular')) {
            require.undef('angular');
            define('angular', [], alt_angular);
        }
    }
function setAlternateAngular ( ) { // This method cannot be called more than once if ( alt_angular ) { throw new Error ( 'setAlternateAngular can only be called once.' ) ; } else { alt_angular = { } ; } // Make sure that bootstrap has been called checkBootstrapped ( ) ; // Create a a copy of orig_angular with on demand loading capability orig_angular . extend ( alt_angular , orig_angular ) ; // Custom version of angular.module used as cache alt_angular . module = function ( name , requires ) { if ( typeof requires === 'undefined' ) { // Return module from alternate_modules if it was created using the alt_angular if ( alternate_modules_tracker . hasOwnProperty ( name ) ) { return alternate_modules [ name ] ; } else { return orig_angular . module ( name ) ; } } else { var orig_mod = orig_angular . module . apply ( null , arguments ) , item = { name : name , module : orig_mod } ; alternate_queue . push ( item ) ; orig_angular . extend ( orig_mod , onDemandLoader ) ; /*
                Use `alternate_modules_tracker` to track which module has been created by alt_angular
                but use `alternate_modules` to cache the module created.  This is to simplify the
                removal of cached modules after .processQueue.
                */ alternate_modules_tracker [ name ] = true ; alternate_modules [ name ] = orig_mod ; // Return created module return orig_mod ; } } ; window . angular = alt_angular ; if ( require . defined ( 'angular' ) ) { require . undef ( 'angular' ) ; define ( 'angular' , [ ] , alt_angular ) ; } }
Create an alternate angular so that subsequent call to angular.module will queue up
the module created for later processing via the .processQueue method.

This delaying processing is needed as angular does not recognize any newly created
module after angular.bootstrap has ran.  The only way to add new objects to angular
post bootstrap is using cached provider.

Once the modules has been queued, processQueue would then use each module's _invokeQueue
and _runBlock to recreate object using cached $provider.  In essence, creating a duplicate
object into the current ng-app.  As result, if there are subsequent call to retrieve the
module post processQueue, it would retrieve a module that is not integrated into the ng-app.

Therefore, any subsequent to call to angular.module after processQueue should return undefined
to prevent obtaining a duplicated object.  However, it is critical that angular.module return
appropriate object *during* processQueue.
Create an alternate angular so that subsequent call to angular . module will queue up the module created for later processing via the . processQueue method .