• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.ApplicationRef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: platformBrowserDynamic

       platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
         const router = res.injector.get(Router);
         spyOn(router, 'resetRootComponentType').and.callThrough();

         const appRef: ApplicationRef = res.injector.get(ApplicationRef);
         appRef.bootstrap(SecondRootCmp);

         expect((router as any).resetRootComponentType).not.toHaveBeenCalled();

         done();
       });
开发者ID:Tim-Shadow,项目名称:angular,代码行数:11,代码来源:bootstrap.spec.ts


示例2: routerFactory

function routerFactory(
    registry: RouteRegistry, location: Location, primaryComponent: Type,
    appRef: ApplicationRef): RootRouter {
  var rootRouter = new RootRouter(registry, location, primaryComponent);
  appRef.registerDisposeListener(() => rootRouter.dispose());
  return rootRouter;
}
开发者ID:JheynsFenix,项目名称:angular,代码行数:7,代码来源:router_providers_common.ts


示例3: expect

      (ref: ApplicationRef) => {

      const compRef = ref.bootstrap(MdlDialogOutletComponent);
      expect(compRef).toBeDefined();
      expect(compRef.instance.viewContainerRef).toBeDefined();

    }))
开发者ID:mseemann,项目名称:angular2-mdl,代码行数:7,代码来源:mdl-dialog-outlet.component.spec.ts


示例4: Error

  open(moduleCFR: ComponentFactoryResolver, contentInjector: Injector, content: any, options): NgbModalRef {
    const containerSelector = options.container || 'body';
    const containerEl = document.querySelector(containerSelector);

    if (!containerEl) {
      throw new Error(`The specified modal container "${containerSelector}" was not found in the DOM.`);
    }

    const activeModal = new NgbActiveModal();
    const contentRef = this._getContentRef(moduleCFR, contentInjector, content, activeModal);

    let windowCmptRef: ComponentRef<NgbModalWindow>;
    let backdropCmptRef: ComponentRef<NgbModalBackdrop>;
    let ngbModalRef: NgbModalRef;


    if (options.backdrop !== false) {
      backdropCmptRef = this._backdropFactory.create(this._injector);
      this._applicationRef.attachView(backdropCmptRef.hostView);
      containerEl.appendChild(backdropCmptRef.location.nativeElement);
    }
    windowCmptRef = this._windowFactory.create(this._injector, contentRef.nodes);
    this._applicationRef.attachView(windowCmptRef.hostView);
    containerEl.appendChild(windowCmptRef.location.nativeElement);

    ngbModalRef = new NgbModalRef(windowCmptRef, contentRef, backdropCmptRef);

    activeModal.close = (result: any) => { ngbModalRef.close(result); };
    activeModal.dismiss = (reason: any) => { ngbModalRef.dismiss(reason); };

    this._applyWindowOptions(windowCmptRef.instance, options);

    return ngbModalRef;
  }
开发者ID:Chenlevin,项目名称:ng-bootstrap,代码行数:34,代码来源:modal-stack.ts


示例5: Error

  open(moduleCFR: ComponentFactoryResolver, contentInjector: Injector, content: any, options): DrawerRef {
    const containerSelector = options.container || 'body';
    const containerEl = document.querySelector(containerSelector);

    if (!containerEl) {
      throw new Error(`The specified drawer container "${containerSelector}" was not found in the DOM.`);
    }

    const activeDrawer = new ActiveDrawer();
    const contentRef = this._getContentRef(moduleCFR, contentInjector, content, activeDrawer);

    let drawerCmptRef: ComponentRef<DrawerComponent>;
    let backdropCmptRef: ComponentRef<DrawerBackdropComponent>;
    let drawerRef: DrawerRef;

    if (options.backdrop !== false) {
      backdropCmptRef = this._backdropFactory.create(this._injector);
      this._applicationRef.attachView(backdropCmptRef.hostView);
      containerEl.appendChild(backdropCmptRef.location.nativeElement);
    }
    drawerCmptRef = this._drawerFactory.create(this._injector, contentRef.nodes);
    this._applicationRef.attachView(drawerCmptRef.hostView);
    containerEl.appendChild(drawerCmptRef.location.nativeElement);

    drawerRef = new DrawerRef(drawerCmptRef, contentRef, backdropCmptRef);

    activeDrawer.close = (result: any) => { drawerRef.close(result); };
    activeDrawer.dismiss = (reason: any) => { drawerRef.dismiss(reason); };

    this.applyDrawerOptions(drawerCmptRef.instance, options);

    return drawerRef;
  }
开发者ID:marlonprudente,项目名称:composer,代码行数:33,代码来源:drawer-stack.ts


示例6: it

  it('should clear appropriate waits when clearPageWait is called', () => {
    waitService.beginNonBlockingPageWait();
    applicationRef.tick();

    waitService.beginBlockingPageWait();
    applicationRef.tick();

    waitService.clearAllPageWaits();
    applicationRef.tick();

    verifyNonBlockingPageWaitExists(false);
    verifyBlockingPageWaitExists(false);
  });
开发者ID:Blackbaud-DanHamlin,项目名称:skyux2,代码行数:13,代码来源:wait.service.spec.ts


示例7: it

  it('should show a modal and return an instance that can then be closed', fakeAsync(() => {
    let modalInstance = openModal(ModalTestComponent);
    applicationRef.tick();

    expect(document.body.querySelector('.sky-modal')).toExist();
    expect(document.body).toHaveCssClass('sky-modal-body-open');
    closeModal(modalInstance);
    tick();
    applicationRef.tick();

    expect(document.body.querySelector('.sky-modal')).not.toExist();
    expect(document.body).not.toHaveCssClass('sky-modal-body-open');
  }));
开发者ID:Blackbaud-DanHamlin,项目名称:skyux2,代码行数:13,代码来源:modal.service.spec.ts


示例8: it

 it('should start from current date if input value is invalid', () => {
   input.value = 'definitely not a date';
   input.dispatchEvent(new Event('input'));
   showRangepicker();
   appRef.tick();
   expect(overlay.querySelector('.day-cell.today')).toBeDefined();
 });
开发者ID:kevinheader,项目名称:nebular,代码行数:7,代码来源:datepicker.spec.ts


示例9:

  /**
   * Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver.
   * @param portal Portal to be attached
   */
  attachComponentPortal<T>(portal: ComponentPortal<T>, newestOnTop: boolean): ComponentRef<T> {
    const componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
    let componentRef: ComponentRef<T>;

    // If the portal specifies a ViewContainerRef, we will use that as the attachment point
    // for the component (in terms of Angular's component tree, not rendering).
    // When the ViewContainerRef is missing, we use the factory to create the component directly
    // and then manually attach the ChangeDetector for that component to the application (which
    // happens automatically when using a ViewContainer).
    componentRef = componentFactory.create(portal.injector);

    // When creating a component outside of a ViewContainer, we need to manually register
    // its ChangeDetector with the application. This API is unfortunately not yet published
    // in Angular core. The change detector must also be deregistered when the component
    // is destroyed to prevent memory leaks.
    this._appRef.attachView(componentRef.hostView);

    this.setDisposeFn(() => {
      this._appRef.detachView(componentRef.hostView);
      componentRef.destroy();
    });

    // At this point the component has been instantiated, so we move it to the location in the DOM
    // where we want it to be rendered.
    if (newestOnTop) {
      this._hostDomElement.insertBefore(this._getComponentRootNode(componentRef), this._hostDomElement.firstChild);
    } else {
      this._hostDomElement.appendChild(this._getComponentRootNode(componentRef));
    }

    return componentRef;
  }
开发者ID:Shivk355,项目名称:mywork,代码行数:36,代码来源:dom-portal-host.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.ChangeDetectorRef类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.AppModuleFactory类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap