• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript element_injector.ProtoElementInjector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: injector

 function injector(bindings, lightDomAppInjector = null, shadowDomAppInjector = null, preBuiltObjects = null, attributes = null) {
   if (isBlank(lightDomAppInjector))
     lightDomAppInjector = appInjector;
   var proto = new ProtoElementInjector(null, 0, bindings, isPresent(shadowDomAppInjector));
   proto.attributes = attributes;
   var inj = proto.instantiate(null, null);
   var preBuilt = isPresent(preBuiltObjects) ? preBuiltObjects : defaultPreBuiltObjects;
   inj.instantiateDirectives(lightDomAppInjector, shadowDomAppInjector, preBuilt);
   return inj;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:element_injector_spec.ts


示例3: it

 it('should pass the host injector when there is no parent injector', () => {
   var pv = new ProtoView(el('<div class="ng-binding"><span class="ng-binding"></span></div>'), new DynamicProtoChangeDetector(null, null), null);
   pv.bindElement(null, 0, new ProtoElementInjector(null, 0, [SomeDirective]));
   var testProtoElementInjector = new TestProtoElementInjector(null, 1, [AnotherDirective]);
   pv.bindElement(null, 0, testProtoElementInjector);
   var hostProtoInjector = new ProtoElementInjector(null, 0, []);
   var hostInjector = hostProtoInjector.instantiate(null, null);
   expect(() => pv.instantiate(hostInjector, null)).not.toThrow();
   expect(testProtoElementInjector.parentElementInjector).toBeNull();
   expect(testProtoElementInjector.hostElementInjector).toBe(hostInjector);
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:11,代码来源:view_spec.ts


示例4: parentChildInjectors

 function parentChildInjectors(parentBindings, childBindings, parentPreBuildObjects = null) {
   if (isBlank(parentPreBuildObjects))
     parentPreBuildObjects = defaultPreBuiltObjects;
   var inj = new Injector([]);
   var protoParent = new ProtoElementInjector(null, 0, parentBindings);
   var parent = protoParent.instantiate(null, null);
   parent.instantiateDirectives(inj, null, parentPreBuildObjects);
   var protoChild = new ProtoElementInjector(protoParent, 1, childBindings, false, 1);
   var child = protoChild.instantiate(parent, null);
   child.instantiateDirectives(inj, null, defaultPreBuiltObjects);
   return child;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:12,代码来源:element_injector_spec.ts


示例5: hostShadowInjectors

 function hostShadowInjectors(hostBindings, shadowBindings, hostPreBuildObjects = null) {
   if (isBlank(hostPreBuildObjects))
     hostPreBuildObjects = defaultPreBuiltObjects;
   var inj = new Injector([]);
   var shadowInj = inj.createChild([]);
   var protoParent = new ProtoElementInjector(null, 0, hostBindings, true);
   var host = protoParent.instantiate(null, null);
   host.instantiateDirectives(inj, shadowInj, hostPreBuildObjects);
   var protoChild = new ProtoElementInjector(protoParent, 0, shadowBindings, false, 1);
   var shadow = protoChild.instantiate(null, host);
   shadow.instantiateDirectives(shadowInj, null, null);
   return shadow;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:13,代码来源:element_injector_spec.ts


示例6: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap