本文整理汇总了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));
}
示例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.');
});
示例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);
});
示例4: metadata
function metadata(type, annotation) {
return DirectiveBinding.createFromType(type, annotation).metadata;
}
示例5: createDirectiveBinding
function createDirectiveBinding(type) {
var annotation = directiveResolver.resolve(type);
return DirectiveBinding.createFromType(type, annotation);
}
示例6: bindDirective
function bindDirective(type) {
return DirectiveBinding.createFromType(type, directiveResolver.resolve(type));
}
示例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);
}
示例8: readDirectiveBinding
function readDirectiveBinding(type) {
var meta = new DirectiveMetadataReader().read(type);
return DirectiveBinding.createFromType(type, meta.annotation);
}