本文整理汇总了TypeScript中angular2/src/core/compiler/element_injector.DirectiveBinding.createFromType方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DirectiveBinding.createFromType方法的具体用法?TypeScript DirectiveBinding.createFromType怎么用?TypeScript DirectiveBinding.createFromType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/core/compiler/element_injector.DirectiveBinding
的用法示例。
在下文中一共展示了DirectiveBinding.createFromType方法的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));
}
示例2: metadata
function metadata(type, annotation) {
return DirectiveBinding.createFromType(type, annotation).metadata;
}
示例3: createDirectiveBinding
function createDirectiveBinding(type) {
var annotation = directiveResolver.resolve(type);
return DirectiveBinding.createFromType(type, annotation);
}
示例4: 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);
}
示例5: bindDirective
function bindDirective(type) {
return DirectiveBinding.createFromType(type, directiveResolver.resolve(type));
}
示例6: readDirectiveBinding
function readDirectiveBinding(type) {
var meta = new DirectiveMetadataReader().read(type);
return DirectiveBinding.createFromType(type, meta.annotation);
}
示例7: 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);
});
示例8: it
it("should call onDestroy on directives subscribed to this event", function() {
var inj = injector([DirectiveBinding.createFromType(DirectiveWithDestroy, new DummyDirective({lifecycle: [onDestroy]}))]);
var destroy = inj.get(DirectiveWithDestroy);
inj.clearDirectives();
expect(destroy.onDestroyCounter).toBe(1);
});