当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript element_injector.DirectiveBinding类代码示例

本文整理汇总了TypeScript中angular2/src/core/compiler/element_injector.DirectiveBinding的典型用法代码示例。如果您正苦于以下问题:TypeScript DirectiveBinding类的具体用法?TypeScript DirectiveBinding怎么用?TypeScript DirectiveBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DirectiveBinding类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var iterations = getIntParameter('iterations');

  reflector.reflectionCapabilities = new ReflectionCapabilities();
  var appInjector = Injector.resolveAndCreate([]);

  var bindings = [
    DirectiveBinding.createFromType(A, null),
    DirectiveBinding.createFromType(B, null),
    DirectiveBinding.createFromType(C, null)
  ];
  var proto = ProtoElementInjector.create(null, 0, bindings, false, 0);
  var elementInjector = proto.instantiate(null);

  function instantiate() {
    for (var i = 0; i < iterations; ++i) {
      var ei = proto.instantiate(null);
      ei.hydrate(appInjector, null, null);
    }
  }

  function hydrate() {
    for (var i = 0; i < iterations; ++i) {
      elementInjector.dehydrate();
      elementInjector.hydrate(appInjector, null, null);
    }
  }

  bindAction('#instantiate', () => microBenchmark('instantiateAvg', iterations, instantiate));
  bindAction('#hydrate', () => microBenchmark('instantiateAvg', iterations, hydrate));
}
开发者ID:B-Thapa,项目名称:angular,代码行数:32,代码来源:element_injector_benchmark.ts

示例2: it

 it("should allow for direct access using getDirectiveBindingAtIndex", function() {
   var binding = DirectiveBinding.createFromBinding(bind(SimpleDirective).toClass(SimpleDirective), null);
   var proto = new ProtoElementInjector(null, 0, [binding]);
   expect(proto.getDirectiveBindingAtIndex(0)).toBeAnInstanceOf(DirectiveBinding);
   expect(() => proto.getDirectiveBindingAtIndex(-1)).toThrowError('Index -1 is out-of-bounds.');
   expect(() => proto.getDirectiveBindingAtIndex(10)).toThrowError('Index 10 is out-of-bounds.');
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:element_injector_spec.ts

示例3: it

 it('should invoke the onAllChangesDone callback', () => {
   var pv = new ProtoView(el('<div class="ng-binding"></div>'), new DynamicProtoChangeDetector(null, null), null);
   pv.bindElement(null, 0, new ProtoElementInjector(null, 0, [DirectiveBinding.createFromType(DirectiveImplementingOnAllChangesDone, new DummyDirective({lifecycle: [onAllChangesDone]}))]));
   createViewAndChangeDetector(pv);
   cd.detectChanges();
   var directive = view.elementInjectors[0].get(DirectiveImplementingOnAllChangesDone);
   expect(directive.onAllChangesDoneCalled).toBe(true);
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:8,代码来源:view_spec.ts

示例4: metadata

 function metadata(type, annotation) {
   return DirectiveBinding.createFromType(type, annotation).metadata;
 }
开发者ID:lavinjj,项目名称:angular,代码行数:3,代码来源:directive_lifecycle_spec.ts

示例5: createDirectiveBinding

 function createDirectiveBinding(type) {
   var annotation = directiveResolver.resolve(type);
   return DirectiveBinding.createFromType(type, annotation);
 }
开发者ID:SnackyPete,项目名称:angular,代码行数:4,代码来源:view_manager_spec.ts

示例6: bindDirective

 function bindDirective(type) {
   return DirectiveBinding.createFromType(type, directiveResolver.resolve(type));
 }
开发者ID:lavinjj,项目名称:angular,代码行数:3,代码来源:proto_view_factory_spec.ts

示例7: createComponentElementBinder

function createComponentElementBinder(reader, type) {
  var meta = reader.read(type);
  var binding = DirectiveBinding.createFromType(meta.type, meta.annotation);
  return new ElementBinder(0, null, 0, null, binding, null);
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:5,代码来源:compiler_spec.ts

示例8: readDirectiveBinding

function readDirectiveBinding(type) {
  var meta = new DirectiveMetadataReader().read(type);
  return DirectiveBinding.createFromType(type, meta.annotation);
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:4,代码来源:view_spec.ts


注:本文中的angular2/src/core/compiler/element_injector.DirectiveBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。