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

Function createInjector

lib/test/angular/1.7.0/angular.js:4855–5122  ·  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

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

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