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


TypeScript index.Services类代码示例

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


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

示例1: it

      it('should query ElementRef', () => {
        class QueryService {
          // TODO(issue/24571): remove '!'.
          a !: ElementRef;
        }

        const {view} = createAndGetRootNodes(compViewDef([
          elementDef(0, NodeFlags.None, [[someQueryId, QueryValueType.ElementRef]], null, 2, 'div'),
          directiveDef(1, NodeFlags.None, null, 1, QueryService, []),
          queryDef(
              NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
              {'a': QueryBindingType.First}),
        ]));

        Services.checkAndUpdateView(view);

        const qs: QueryService = asProviderData(view, 1).instance;
        expect(qs.a.nativeElement).toBe(asElementData(view, 0).renderElement);
      });
开发者ID:Cammisuli,项目名称:angular,代码行数:19,代码来源:query_spec.ts

示例2: it

      it('should query providers on the same element and child elements', () => {
        const {view} = createAndGetRootNodes(compViewDef([
          elementDef(NodeFlags.None, null, null, 5, 'div'),
          ...contentQueryProviders(),
          aServiceProvider(),
          elementDef(NodeFlags.None, null, null, 1, 'div'),
          aServiceProvider(),
        ]));

        const qs: QueryService = asProviderData(view, 1).instance;
        expect(qs.a).toBeUndefined();

        Services.checkAndUpdateView(view);

        const as = qs.a.toArray();
        expect(as.length).toBe(2);
        expect(as[0]).toBe(asProviderData(view, 3).instance);
        expect(as[1]).toBe(asProviderData(view, 5).instance);
      });
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:19,代码来源:query_spec.ts

示例3: it

      it('should query the first match', () => {
        class QueryService {
          a: AService;
        }

        const {view} = createAndGetRootNodes(compViewDef([
          elementDef(NodeFlags.None, null, null, 4, 'div'),
          directiveDef(NodeFlags.None, null, 1, QueryService, []),
          queryDef(
              NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
              {'a': QueryBindingType.First}),
          aServiceProvider(),
          aServiceProvider(),
        ]));

        Services.checkAndUpdateView(view);

        const qs: QueryService = asProviderData(view, 1).instance;
        expect(qs.a).toBe(asProviderData(view, 3).instance);
      });
开发者ID:ballipongala,项目名称:angular,代码行数:20,代码来源:query_spec.ts

示例4: it

        it(`should update ${ArgumentType[inlineDynamic]}`, () => {
          const {view, rootNodes} = createAndGetRootNodes(compViewDef(
              [
                elementDef(
                    NodeFlags.None, null, null, 0, 'div', null,
                    [
                      [BindingType.ElementStyle, 'width', 'px'],
                      [BindingType.ElementStyle, 'color', null]
                    ]),
              ],
              null, (check, view) => {
                checkNodeInlineOrDynamic(check, view, 0, inlineDynamic, [10, 'red']);
              }));

          Services.checkAndUpdateView(view);

          const el = rootNodes[0];
          expect(getDOM().getStyle(el, 'width')).toBe('10px');
          expect(getDOM().getStyle(el, 'color')).toBe('red');
        });
开发者ID:rlugojr,项目名称:angular,代码行数:20,代码来源:element_spec.ts

示例5: it

        it(`should update via strategy ${inlineDynamic}`, () => {
          const {view, rootNodes} = createAndGetRootNodes(compViewDef(
              [
                elementDef(
                    0, NodeFlags.None, null, null, 0, 'div', null,
                    [
                      [BindingFlags.TypeElementClass, 'c1', null],
                      [BindingFlags.TypeElementClass, 'c2', null],
                    ]),
              ],
              (check, view) => {
                checkNodeInlineOrDynamic(check, view, 0, inlineDynamic, [true, true]);
              }));

          Services.checkAndUpdateView(view);

          const el = rootNodes[0];
          expect(getDOM().hasClass(el, 'c1')).toBeTruthy();
          expect(getDOM().hasClass(el, 'c2')).toBeTruthy();
        });
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:20,代码来源:element_spec.ts

示例6: 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, null, embeddedViewDef([
                    ngContentDef(null, 0),
                    // The anchor would be added by the compiler after the ngContent
                    anchorDef(NodeFlags.None, null, null, 0),
                  ])),
      ])));

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

      attachEmbeddedView(view, asElementData(componentView, 1), 0, view0);
      expect(getDOM().childNodes(getDOM().firstChild(rootNodes[0])).length).toBe(3);
      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:rlugojr,项目名称:angular,代码行数:21,代码来源:ng_content_spec.ts


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