本文整理汇总了TypeScript中@angular/core/src/view/index.directiveDef函数的典型用法代码示例。如果您正苦于以下问题:TypeScript directiveDef函数的具体用法?TypeScript directiveDef怎么用?TypeScript directiveDef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了directiveDef函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should calculate childMatchedQueries for one level, multiple roots', () => {
const vd = viewDef(ViewFlags.None, [
elementDef(NodeFlags.None, null, null, 1, 'span'),
directiveDef(NodeFlags.None, [['q1', QueryValueType.Provider]], 0, AService, []),
elementDef(NodeFlags.None, null, null, 2, 'span'),
directiveDef(NodeFlags.None, [['q2', QueryValueType.Provider]], 0, AService, []),
directiveDef(NodeFlags.None, [['q3', QueryValueType.Provider]], 0, AService, []),
]);
expect(childMatchedQueries(vd)).toEqual([['q1'], [], ['q2', 'q3'], [], []]);
});
开发者ID:doxiaodong,项目名称:angular,代码行数:11,代码来源:view_def_spec.ts
示例2: it
it('should calculate childMatchedQueries for one level, multiple roots', () => {
const vd = viewDef(ViewFlags.None, [
elementDef(NodeFlags.None, null, null, 1, 'span'),
directiveDef(NodeFlags.None, [[1, QueryValueType.Provider]], 0, AService, []),
elementDef(NodeFlags.None, null, null, 2, 'span'),
directiveDef(NodeFlags.None, [[2, QueryValueType.Provider]], 0, AService, []),
directiveDef(NodeFlags.None, [[3, QueryValueType.Provider]], 0, AService, []),
]);
expect(childMatchedQueries(vd)).toEqual([
filterQueryId(1), 0, filterQueryId(2) | filterQueryId(3), 0, 0
]);
});
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:13,代码来源:view_def_spec.ts
示例3: it
it('should calculate childFlags for one level, multiple roots', () => {
const vd = viewDef(ViewFlags.None, [
elementDef(NodeFlags.None, null, null, 1, 'span'),
directiveDef(NodeFlags.AfterContentChecked, null, 0, AService, []),
elementDef(NodeFlags.None, null, null, 2, 'span'),
directiveDef(NodeFlags.AfterContentInit, null, 0, AService, []),
directiveDef(NodeFlags.AfterViewChecked, null, 0, AService, []),
]);
expect(childFlags(vd)).toEqual([
NodeFlags.AfterContentChecked, NodeFlags.None,
NodeFlags.AfterContentInit | NodeFlags.AfterViewChecked, NodeFlags.None, NodeFlags.None
]);
});
开发者ID:manekinekko,项目名称:angular,代码行数:14,代码来源:view_def_spec.ts
示例4: it
it('should query all matches', () => {
class QueryService {
// TODO(issue/24571): remove '!'.
a !: QueryList<AService>;
}
const {view} = createAndGetRootNodes(compViewDef([
elementDef(0, NodeFlags.None, null, null, 4, 'div'),
directiveDef(1, NodeFlags.None, null, 1, QueryService, []),
queryDef(
NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
{'a': QueryBindingType.All}),
aServiceProvider(3),
aServiceProvider(4),
]));
Services.checkAndUpdateView(view);
const qs: QueryService = asProviderData(view, 1).instance;
expect(qs.a instanceof QueryList).toBeTruthy();
expect(qs.a.toArray()).toEqual([
asProviderData(view, 3).instance,
asProviderData(view, 4).instance,
]);
});
开发者ID:Cammisuli,项目名称:angular,代码行数:25,代码来源:query_spec.ts
示例5: it
it('should not stop dirty checking views that threw errors in change detection', () => {
class AComp {
a: any;
}
const update = jasmine.createSpy('updater');
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
elementDef(
0, NodeFlags.None, null, null, 1, 'div', null, null, null, null,
() => compViewDef(
[elementDef(
0, NodeFlags.None, null, null, 0, 'span', null,
[[BindingFlags.TypeElementAttribute, 'a', SecurityContext.NONE]])],
null, update)),
directiveDef(1, NodeFlags.Component, null, 0, AComp, [], null, null, ),
]));
update.and.callFake((check: NodeCheckFn, view: ViewData) => { throw new Error('Test'); });
expect(() => Services.checkAndUpdateView(view)).toThrowError('Test');
expect(update).toHaveBeenCalled();
update.calls.reset();
expect(() => Services.checkAndUpdateView(view)).toThrowError('Test');
expect(update).toHaveBeenCalled();
});
开发者ID:Rowmance,项目名称:angular,代码行数:26,代码来源:component_view_spec.ts
示例6: createAndGetRootNodes
() => {
class AComp {
a: any;
}
const update = jasmine.createSpy('updater');
const {view, rootNodes} = createAndGetRootNodes(compViewDef([
elementDef(NodeFlags.None, null, null, 1, 'div', null, null, null, null, () => compViewDef(
[
elementDef(NodeFlags.None, null, null, 0, 'span', null, [[BindingType.ElementAttribute, 'a', SecurityContext.NONE]]),
],
null, update)),
directiveDef(
NodeFlags.IsComponent, null, 0, AComp, [], null, null,
),
]));
const compView = asElementData(view, 0).componentView;
update.and.callFake(
(check: NodeCheckFn, view: ViewData) => { throw new Error('Test'); });
expect(() => Services.checkAndUpdateView(view)).toThrowError('Test');
expect(update).toHaveBeenCalled();
update.calls.reset();
Services.checkAndUpdateView(view);
expect(update).not.toHaveBeenCalled();
});
开发者ID:rlugojr,项目名称:angular,代码行数:29,代码来源:component_view_spec.ts
示例7: it
it(`should support ${ArgumentType[inlineDynamic]} bindings`, () => {
let values: any[];
const {view, rootNodes} = createAndGetRootNodes(compViewDef(
[
elementDef(NodeFlags.None, null, null, 2, 'span'), pureArrayDef(2),
directiveDef(NodeFlags.None, null, 0, Service, [], {data: [0, 'data']})
],
(check, view) => {
const pureValue = checkNodeInlineOrDynamic(check, view, 1, inlineDynamic, values);
checkNodeInlineOrDynamic(check, view, 2, inlineDynamic, [pureValue]);
}));
const service = asProviderData(view, 2).instance;
values = [1, 2];
Services.checkAndUpdateView(view);
const arr0 = service.data;
expect(arr0).toEqual([1, 2]);
// instance should not change
// if the values don't change
Services.checkAndUpdateView(view);
expect(service.data).toBe(arr0);
values = [3, 2];
Services.checkAndUpdateView(view);
const arr1 = service.data;
expect(arr1).not.toBe(arr0);
expect(arr1).toEqual([3, 2]);
});
开发者ID:rlugojr,项目名称:angular,代码行数:30,代码来源:pure_expression_spec.ts
示例8: it
it('report the binding name when an expression changes after it has been checked', () => {
let value: any;
class AComp {}
const update =
jasmine.createSpy('updater').and.callFake((check: NodeCheckFn, view: ViewData) => {
check(view, 0, ArgumentType.Inline, 'const', 'const', value);
});
const {view, rootNodes} = createAndGetRootNodes(
compViewDef([
elementDef(0, NodeFlags.None, null, null, 1, 'div', null, null, null, null, () => compViewDef([
elementDef(0, NodeFlags.None, null, null, 0, 'span', null, [
[BindingFlags.TypeElementAttribute, 'p1', SecurityContext.NONE],
[BindingFlags.TypeElementAttribute, 'p2', SecurityContext.NONE],
[BindingFlags.TypeElementAttribute, 'p3', SecurityContext.NONE],
]),
], null, update)
),
directiveDef(1, NodeFlags.Component, null, 0, AComp, []),
]));
value = 'v1';
Services.checkAndUpdateView(view);
value = 'v2';
expect(() => Services.checkNoChangesView(view))
.toThrowError(
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'p3: v1'. Current value: 'p3: v2'.`);
});
开发者ID:IdeaBlade,项目名称:angular,代码行数:29,代码来源:component_view_spec.ts
示例9: it
it('should project already attached embedded views', () => {
class CreateViewService {
constructor(templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef) {
viewContainerRef.createEmbeddedView(templateRef);
}
}
const {view, rootNodes} =
createAndGetRootNodes(
compViewDef(
hostElDef(0,
[
anchorDef(
NodeFlags.EmbeddedViews, null, 0, 1, null,
compViewDefFactory([textDef(0, null, ['a'])])),
directiveDef(3,
NodeFlags.None, null, 0, CreateViewService,
[TemplateRef, ViewContainerRef]),
],
[
elementDef(0, NodeFlags.None, null, null, 1, 'div'),
ngContentDef(null, 0),
])));
const anchor = asElementData(view, 2);
expect((getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[0]))
.toBe(anchor.renderElement);
const embeddedView = anchor.viewContainer !._embeddedViews[0];
expect((getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[1]))
.toBe(asTextData(embeddedView, 0).renderText);
});
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:31,代码来源:ng_content_spec.ts
注:本文中的@angular/core/src/view/index.directiveDef函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论