MCPcopy
hub / github.com/angular-ui/ui-router / loadModules

Function loadModules

test/angular/1.2/angular.js:3871–3912  ·  view source on GitHub ↗
(modulesToLoad)

Source from the content-addressed store, hash-verified

3869 // Module Loading
3870 ////////////////////////////////////
3871 function loadModules(modulesToLoad){
3872 var runBlocks = [], moduleFn, invokeQueue, i, ii;
3873 forEach(modulesToLoad, function(module) {
3874 if (loadedModules.get(module)) return;
3875 loadedModules.put(module, true);
3876
3877 try {
3878 if (isString(module)) {
3879 moduleFn = angularModule(module);
3880 runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
3881
3882 for(invokeQueue = moduleFn._invokeQueue, i = 0, ii = invokeQueue.length; i < ii; i++) {
3883 var invokeArgs = invokeQueue[i],
3884 provider = providerInjector.get(invokeArgs[0]);
3885
3886 provider[invokeArgs[1]].apply(provider, invokeArgs[2]);
3887 }
3888 } else if (isFunction(module)) {
3889 runBlocks.push(providerInjector.invoke(module));
3890 } else if (isArray(module)) {
3891 runBlocks.push(providerInjector.invoke(module));
3892 } else {
3893 assertArgFn(module, 'module');
3894 }
3895 } catch (e) {
3896 if (isArray(module)) {
3897 module = module[module.length - 1];
3898 }
3899 if (e.message && e.stack && e.stack.indexOf(e.message) == -1) {
3900 // Safari & FF's stack traces don't contain error.message content
3901 // unlike those of Chrome and IE
3902 // So if stack doesn't contain message, we create a new string that contains both.
3903 // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
3904 /* jshint -W022 */
3905 e = e.message + '\n' + e.stack;
3906 }
3907 throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}",
3908 module, e.stack || e.message || e);
3909 }
3910 });
3911 return runBlocks;
3912 }
3913
3914 ////////////////////////////////////
3915 // internal Injector

Callers 1

createInjectorFunction · 0.70

Calls 5

isArrayFunction · 0.85
forEachFunction · 0.70
isStringFunction · 0.70
isFunctionFunction · 0.70
assertArgFnFunction · 0.70

Tested by

no test coverage detected