本文整理汇总了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;未经允许,请勿转载。 |
请发表评论