(modulesToLoad)
| 5017 | // Module Loading |
| 5018 | //////////////////////////////////// |
| 5019 | function loadModules(modulesToLoad) { |
| 5020 | assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array'); |
| 5021 | var runBlocks = [], moduleFn; |
| 5022 | forEach(modulesToLoad, function(module) { |
| 5023 | if (loadedModules.get(module)) return; |
| 5024 | loadedModules.set(module, true); |
| 5025 | |
| 5026 | function runInvokeQueue(queue) { |
| 5027 | var i, ii; |
| 5028 | for (i = 0, ii = queue.length; i < ii; i++) { |
| 5029 | var invokeArgs = queue[i], |
| 5030 | provider = providerInjector.get(invokeArgs[0]); |
| 5031 | |
| 5032 | provider[invokeArgs[1]].apply(provider, invokeArgs[2]); |
| 5033 | } |
| 5034 | } |
| 5035 | |
| 5036 | try { |
| 5037 | if (isString(module)) { |
| 5038 | moduleFn = angularModule(module); |
| 5039 | instanceInjector.modules[module] = moduleFn; |
| 5040 | runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks); |
| 5041 | runInvokeQueue(moduleFn._invokeQueue); |
| 5042 | runInvokeQueue(moduleFn._configBlocks); |
| 5043 | } else if (isFunction(module)) { |
| 5044 | runBlocks.push(providerInjector.invoke(module)); |
| 5045 | } else if (isArray(module)) { |
| 5046 | runBlocks.push(providerInjector.invoke(module)); |
| 5047 | } else { |
| 5048 | assertArgFn(module, 'module'); |
| 5049 | } |
| 5050 | } catch (e) { |
| 5051 | if (isArray(module)) { |
| 5052 | module = module[module.length - 1]; |
| 5053 | } |
| 5054 | if (e.message && e.stack && e.stack.indexOf(e.message) === -1) { |
| 5055 | // Safari & FF's stack traces don't contain error.message content |
| 5056 | // unlike those of Chrome and IE |
| 5057 | // So if stack doesn't contain message, we create a new string that contains both. |
| 5058 | // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here. |
| 5059 | // eslint-disable-next-line no-ex-assign |
| 5060 | e = e.message + '\n' + e.stack; |
| 5061 | } |
| 5062 | throw $injectorMinErr('modulerr', 'Failed to instantiate module {0} due to:\n{1}', |
| 5063 | module, e.stack || e.message || e); |
| 5064 | } |
| 5065 | }); |
| 5066 | return runBlocks; |
| 5067 | } |
| 5068 | |
| 5069 | //////////////////////////////////// |
| 5070 | // internal Injector |
no test coverage detected