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

Function createInjector

lib/test/angular/1.8.0/angular.js:4970–5237  ·  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

4968
4969
4970function createInjector(modulesToLoad, strictDi) {
4971 strictDi = (strictDi === true);
4972 var INSTANTIATING = {},
4973 providerSuffix = 'Provider',
4974 path = [],
4975 loadedModules = new NgMap(),
4976 providerCache = {
4977 $provide: {
4978 provider: supportObject(provider),
4979 factory: supportObject(factory),
4980 service: supportObject(service),
4981 value: supportObject(value),
4982 constant: supportObject(constant),
4983 decorator: decorator
4984 }
4985 },
4986 providerInjector = (providerCache.$injector =
4987 createInternalInjector(providerCache, function(serviceName, caller) {
4988 if (angular.isString(caller)) {
4989 path.push(caller);
4990 }
4991 throw $injectorMinErr('unpr', 'Unknown provider: {0}', path.join(' <- '));
4992 })),
4993 instanceCache = {},
4994 protoInstanceInjector =
4995 createInternalInjector(instanceCache, function(serviceName, caller) {
4996 var provider = providerInjector.get(serviceName + providerSuffix, caller);
4997 return instanceInjector.invoke(
4998 provider.$get, provider, undefined, serviceName);
4999 }),
5000 instanceInjector = protoInstanceInjector;
5001
5002 providerCache['$injector' + providerSuffix] = { $get: valueFn(protoInstanceInjector) };
5003 instanceInjector.modules = providerInjector.modules = createMap();
5004 var runBlocks = loadModules(modulesToLoad);
5005 instanceInjector = protoInstanceInjector.get('$injector');
5006 instanceInjector.strictDi = strictDi;
5007 forEach(runBlocks, function(fn) { if (fn) instanceInjector.invoke(fn); });
5008
5009 instanceInjector.loadNewModules = function(mods) {
5010 forEach(loadModules(mods), function(fn) { if (fn) instanceInjector.invoke(fn); });
5011 };
5012
5013
5014 return instanceInjector;
5015
5016 ////////////////////////////////////
5017 // $provider
5018 ////////////////////////////////////
5019
5020 function supportObject(delegate) {
5021 return function(key, value) {
5022 if (isObject(key)) {
5023 forEach(key, reverseParams(delegate));
5024 } else {
5025 return delegate(key, value);
5026 }
5027 };

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