MCPcopy
hub / github.com/angular-ui/ui-grid / createInjector

Function createInjector

lib/test/angular/1.6.7/angular.js:4857–5126  ·  view source on GitHub ↗

* @ngdoc method * @name $provide#decorator * @description * * Register a **decorator function** with the auto.$injector $injector. A decorator function * intercepts the creation of a service, allowing it to override or modify the behavior of the * service. The return value of the decor

(modulesToLoad, strictDi)

Source from the content-addressed store, hash-verified

4855
4856
4857function createInjector(modulesToLoad, strictDi) {
4858 strictDi = (strictDi === true);
4859 var INSTANTIATING = {},
4860 providerSuffix = 'Provider',
4861 path = [],
4862 loadedModules = new NgMap(),
4863 providerCache = {
4864 $provide: {
4865 provider: supportObject(provider),
4866 factory: supportObject(factory),
4867 service: supportObject(service),
4868 value: supportObject(value),
4869 constant: supportObject(constant),
4870 decorator: decorator
4871 }
4872 },
4873 providerInjector = (providerCache.$injector =
4874 createInternalInjector(providerCache, function(serviceName, caller) {
4875 if (angular.isString(caller)) {
4876 path.push(caller);
4877 }
4878 throw $injectorMinErr('unpr', 'Unknown provider: {0}', path.join(' <- '));
4879 })),
4880 instanceCache = {},
4881 protoInstanceInjector =
4882 createInternalInjector(instanceCache, function(serviceName, caller) {
4883 var provider = providerInjector.get(serviceName + providerSuffix, caller);
4884 return instanceInjector.invoke(
4885 provider.$get, provider, undefined, serviceName);
4886 }),
4887 instanceInjector = protoInstanceInjector;
4888
4889 providerCache['$injector' + providerSuffix] = { $get: valueFn(protoInstanceInjector) };
4890 instanceInjector.modules = providerInjector.modules = createMap();
4891 var runBlocks = loadModules(modulesToLoad);
4892 instanceInjector = protoInstanceInjector.get('$injector');
4893 instanceInjector.strictDi = strictDi;
4894 forEach(runBlocks, function(fn) { if (fn) instanceInjector.invoke(fn); });
4895
4896 instanceInjector.loadNewModules = function(mods) {
4897 forEach(loadModules(mods), function(fn) { if (fn) instanceInjector.invoke(fn); });
4898 };
4899
4900
4901 return instanceInjector;
4902
4903 ////////////////////////////////////
4904 // $provider
4905 ////////////////////////////////////
4906
4907 function supportObject(delegate) {
4908 return function(key, value) {
4909 if (isObject(key)) {
4910 forEach(key, reverseParams(delegate));
4911 } else {
4912 return delegate(key, value);
4913 }
4914 };

Callers 1

doBootstrapFunction · 0.70

Calls 6

supportObjectFunction · 0.70
createInternalInjectorFunction · 0.70
valueFnFunction · 0.70
createMapFunction · 0.70
loadModulesFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected