当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript index.asTextData函数代码示例

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


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

示例1: it

    it('should create views with multiple root ng-content nodes', () => {
      const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef(
          [textDef(0, ['a']), textDef(1, ['b'])], [ngContentDef(null, 0), ngContentDef(null, 1)])));

      expect(getDOM().childNodes(rootNodes[0])[0]).toBe(asTextData(view, 2).renderText);
      expect(getDOM().childNodes(rootNodes[0])[1]).toBe(asTextData(view, 3).renderText);
    });
开发者ID:rlugojr,项目名称:angular,代码行数:7,代码来源:ng_content_spec.ts

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

示例3: it

      it('should provide data for text nodes', () => {
        const view = createViewWithData();
        const compView = asElementData(view, 0).componentView;

        const debugCtx = Services.createDebugContext(compView, 2);

        expect(debugCtx.componentRenderElement).toBe(asElementData(view, 0).renderElement);
        expect(debugCtx.renderNode).toBe(asTextData(compView, 2).renderText);
        expect(debugCtx.injector.get(AComp)).toBe(compView.component);
        expect(debugCtx.component).toBe(compView.component);
        expect(debugCtx.context).toBe(compView.context);
      });
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:12,代码来源:services_spec.ts

示例4: it

    it('should include projected nodes when attaching / detaching embedded views', () => {
      const {view, rootNodes} = createAndGetRootNodes(compViewDef(hostElDef([textDef(0, ['a'])], [
        elementDef(NodeFlags.None, null, null, 1, 'div'),
        anchorDef(NodeFlags.HasEmbeddedViews, null, 0, 0, embeddedViewDef([ngContentDef(null, 0)])),
      ])));

      const componentView = asProviderData(view, 1).componentView;
      const view0 = createEmbeddedView(componentView, componentView.def.nodes[1]);

      attachEmbeddedView(asElementData(componentView, 1), 0, view0);
      expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0])).length).toBe(2);
      expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0]))[1])
          .toBe(asTextData(view, 2).renderText);

      detachEmbeddedView(asElementData(componentView, 1), 0);
      expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0])).length).toBe(1);
    });
开发者ID:doxiaodong,项目名称:angular,代码行数:17,代码来源:ng_content_spec.ts

示例5: it

 it('should add debug information to the renderer', () => {
   const someContext = new Object();
   const {view, rootNodes} =
       createAndGetRootNodes(compViewDef([textDef(null, ['a'])]), someContext);
   expect(getDebugNode(rootNodes[0]).nativeNode).toBe(asTextData(view, 0).renderText);
 });
开发者ID:rlugojr,项目名称:angular,代码行数:6,代码来源:text_spec.ts


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