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


TypeScript Services.destroyView方法代码示例

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


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

示例1: it

        it('should listen to document events', () => {
          const handleEventSpy = jasmine.createSpy('handleEvent');
          const addListenerSpy = spyOn(document, 'addEventListener');
          const removeListenerSpy = spyOn(document, 'removeEventListener');
          const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef(
              [elementDef(
                  NodeFlags.None, null, null, 0, 'button', null, null,
                  [['document', 'documentClick']])],
              null, null, handleEventSpy));

          expect(addListenerSpy).toHaveBeenCalled();
          expect(addListenerSpy.calls.mostRecent().args[0]).toBe('documentClick');
          addListenerSpy.calls.mostRecent().args[1]({name: 'documentClick'});

          expect(handleEventSpy).toHaveBeenCalled();
          const handleEventArgs = handleEventSpy.calls.mostRecent().args;
          expect(handleEventArgs[0]).toBe(view);
          expect(handleEventArgs[1]).toBe(0);
          expect(handleEventArgs[2]).toBe('document:documentClick');
          expect(handleEventArgs[3]).toBeTruthy();

          Services.destroyView(view);

          expect(removeListenerSpy).toHaveBeenCalled();
        });
开发者ID:tolemac,项目名称:angular,代码行数:25,代码来源:element_spec.ts

示例2: it

      it('should throw on dirty checking destroyed views', () => {
        const {view, rootNodes} = createAndGetRootNodes(
            compViewDef([elementDef(0, NodeFlags.None, null, null, 0, 'div')]));

        Services.destroyView(view);

        expect(() => Services.checkAndUpdateView(view))
            .toThrowError('ViewDestroyedError: Attempt to use a destroyed view: detectChanges');
      });
开发者ID:Rowmance,项目名称:angular,代码行数:9,代码来源:component_view_spec.ts

示例3: it

        it('should listen to DOM events', () => {
          const handleEventSpy = jasmine.createSpy('handleEvent');
          const removeListenerSpy =
              spyOn(HTMLElement.prototype, 'removeEventListener').and.callThrough();
          const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
              NodeFlags.None, null, null, 0, 'button', null, null, [[null, 'click']],
              handleEventSpy)]));

          rootNodes[0].click();

          expect(handleEventSpy).toHaveBeenCalled();
          let handleEventArgs = handleEventSpy.calls.mostRecent().args;
          expect(handleEventArgs[0]).toBe(view);
          expect(handleEventArgs[1]).toBe('click');
          expect(handleEventArgs[2]).toBeTruthy();

          Services.destroyView(view);

          expect(removeListenerSpy).toHaveBeenCalled();
        });
开发者ID:rlugojr,项目名称:angular,代码行数:20,代码来源:element_spec.ts

示例4: it

    it('should destroy embedded views', () => {
      const log: string[] = [];

      class ChildProvider {
        ngOnDestroy() { log.push('ngOnDestroy'); };
      }

      const {view: parentView} = createAndGetRootNodes(compViewDef([
        elementDef(NodeFlags.None, null, null, 1, 'div'),
        anchorDef(NodeFlags.EmbeddedViews, null, null, 0, null, embeddedViewDef([
                    elementDef(NodeFlags.None, null, null, 1, 'span'),
                    directiveDef(NodeFlags.OnDestroy, null, 0, ChildProvider, [])
                  ]))
      ]));

      const childView0 = Services.createEmbeddedView(parentView, parentView.def.nodes[1]);

      attachEmbeddedView(parentView, asElementData(parentView, 1), 0, childView0);
      Services.destroyView(parentView);

      expect(log).toEqual(['ngOnDestroy']);
    });
开发者ID:JohnnyQQQQ,项目名称:angular,代码行数:22,代码来源:embedded_view_spec.ts

示例5: it

        it('should listen to window events', () => {
          const handleEventSpy = jasmine.createSpy('handleEvent');
          const addListenerSpy = spyOn(window, addEventListener);
          const removeListenerSpy = spyOn(window, removeEventListener);
          const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
              0, NodeFlags.None, null, null, 0, 'button', null, null, [['window', 'windowClick']],
              handleEventSpy)]));

          expect(addListenerSpy).toHaveBeenCalled();
          expect(addListenerSpy.calls.mostRecent().args[0]).toBe('windowClick');
          callMostRecentEventListenerHandler(addListenerSpy, {name: 'windowClick'});

          expect(handleEventSpy).toHaveBeenCalled();
          const handleEventArgs = handleEventSpy.calls.mostRecent().args;
          expect(handleEventArgs[0]).toBe(view);
          expect(handleEventArgs[1]).toBe('window:windowClick');
          expect(handleEventArgs[2]).toBeTruthy();

          Services.destroyView(view);

          expect(removeListenerSpy).toHaveBeenCalled();
        });
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:22,代码来源:element_spec.ts


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