當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript index.directiveDef函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。