當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。