How to use the di/di.Injector function in di

To help you get started, we’ve selected a few di examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular / modules / benchmarks / src / element_injector / instantiate_directive_benchmark.js View on Github external
export function run () {
  var appInjector = new Injector([]);

  var bindings = [A, B, C];
  var proto = new ProtoElementInjector(null, 0, bindings);
  var ei = proto.instantiate(null,null);

  for (var i = 0; i < ITERATIONS; ++i) {
    ei.clearDirectives();
    ei.instantiateDirectives(appInjector, null, null);
  }
}
github angular / angular / modules / benchmarks / src / element_injector / instantiate_benchmark_codegen.js View on Github external
export function run () {
  var appInjector = new Injector([]);

  var bindings = [
    new Binding(Key.get(A), () => new A(), [], false),
    new Binding(Key.get(B), () => new B(), [], false),
    new Binding(Key.get(C), (a,b) => new C(a,b), [
      new Dependency(Key.get(A), false, false, []),
      new Dependency(Key.get(B), false, false, [])
    ], false)];


  var proto = new ProtoElementInjector(null, 0, bindings);
  for (var i = 0; i < ITERATIONS; ++i) {
    var ei = proto.instantiate(null,null);
    ei.instantiateDirectives(appInjector, null, null);
  }
}
github angular / angular / modules / benchmarks / src / di / injector_instantiate_benchmark.js View on Github external
export function run () {
  var bindings = [A, B, C, D];
  var injector = new Injector(bindings);

  for (var i = 0; i < 1000; ++i) {
    var child = injector.createChild([E]);
    child.get(E);
  }
}