@angular/cdk/overlay#OverlayRef TypeScript Examples

The following examples show how to use @angular/cdk/overlay#OverlayRef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: modal.service.ts    From sba-angular with MIT License 6 votes vote down vote up
private attachDialogContainer(component: Type<any>, overlayRef: OverlayRef, config: ModalConfig, modalRef: ModalRef) {
        // PortalInjector() is deprecated
        const injector = Injector.create({
            providers:[
                {provide: ModalRef, useValue: modalRef},
                {provide: MODAL_MODEL, useValue: config.model}
            ], 
            parent:this.injector
        });
        const containerPortal = new ComponentPortal(component, null, injector);
        const containerRef = overlayRef.attach<Type<any>>(containerPortal);

        return containerRef.instance;
    }
Example #2
Source File: np-modal-ref.ts    From np-ui-lib with MIT License 6 votes vote down vote up
constructor(
    public overlay: OverlayRef,
    public content: string | TemplateRef<any> | Type<any>,
    public config: NpModalConfig,
    public data: any
  ) {
    overlay.backdropClick().subscribe(() => {
      if (config.closeOnClickOutside === true) {
        this._close(null);
      }
    });
  }
Example #3
Source File: base-tooltip.ts    From alauda-ui with MIT License 6 votes vote down vote up
protected createOverlay(): OverlayRef {
    const originPosition = getOriginPosition(this.position);
    const overlayPosition = getOverlayPosition(this.position);

    const positionStrategy = this.overlay
      .position()
      .flexibleConnectedTo(this.elRef)
      .withGrowAfterOpen(true)
      .withPositions([
        { ...originPosition.main, ...overlayPosition.main },
        { ...originPosition.fallback, ...overlayPosition.fallback },
      ]);

    const scrollStrategy = this.overlay.scrollStrategies.reposition();

    const config = new OverlayConfig({
      positionStrategy,
      scrollStrategy,
    });
    return this.overlay.create(config);
  }
Example #4
Source File: loader.service.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 6 votes vote down vote up
open(): OverlayRef {
    if (this.overlayRef) {
      return this.overlayRef;
    }
    const positionStrategy: GlobalPositionStrategy = this.overlay
      .position()
      .global()
      .centerHorizontally()
      .centerVertically();
    const overlayConfig = new OverlayConfig({
      hasBackdrop: true,
      positionStrategy,
    });
    const overlayRef = this.overlay.create(overlayConfig);
    const portal = new ComponentPortal(SpinnerLoaderComponent);
    overlayRef.attach(portal);
    this.overlayRef = overlayRef;
    return this.overlayRef;
  }
Example #5
Source File: dialog.service.ts    From alauda-ui with MIT License 6 votes vote down vote up
private attachDialogContent<T, D, R>(
    compOrTempRef: ComponentType<T> | TemplateRef<T>,
    dialogIns: DialogComponent,
    overlayRef: OverlayRef,
    config: DialogConfig<D>,
  ): DialogRef<T, R> {
    const dialogRef = new DialogRef<T, R>(
      overlayRef,
      dialogIns,
      this.scrollDispatcher,
      this.ngZone,
    );

    if (compOrTempRef instanceof TemplateRef) {
      dialogIns.attachTemplatePortal(
        new TemplatePortal(compOrTempRef, null, {
          $implicit: config.data,
        } as any),
      );
    } else {
      const injector = this.createInjector(config, dialogRef, dialogIns);
      const contentRef = dialogIns.attachComponentPortal<T>(
        new ComponentPortal(compOrTempRef, null, injector),
      );
      dialogRef.componentInstance = contentRef.instance;
    }
    return dialogRef;
  }
Example #6
Source File: dialog.service.ts    From alauda-ui with MIT License 6 votes vote down vote up
private attachDialog(
    overlayRef: OverlayRef,
    config: DialogConfig,
  ): DialogComponent {
    const dialogPortal = new ComponentPortal(
      DialogComponent,
      config.viewContainerRef,
    );
    const dialogRef = overlayRef.attach(dialogPortal);
    dialogRef.instance.config = config;
    return dialogRef.instance;
  }
Example #7
Source File: dialog-ref.ts    From alauda-ui with MIT License 6 votes vote down vote up
constructor(
    private readonly overlayRef: OverlayRef,
    public dialogInstance: DialogComponent,
    scrollDispatcher: ScrollDispatcher,
    ngZone: NgZone,
  ) {
    dialogInstance.id = this.id;
    this.scrollable = new CdkScrollable(
      { nativeElement: overlayRef.overlayElement },
      scrollDispatcher,
      ngZone,
    );
    this.scrollable.ngOnInit();
  }
Example #8
Source File: router-outlet-context.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
constructor(host: ElementRef<HTMLElement>,
              formBuilder: FormBuilder,
              public routerOutlet: SciRouterOutletElement,
              private _overlay: OverlayRef) {
    this.form = new FormGroup({
      [NAME]: formBuilder.control('', Validators.required),
      [VALUE]: formBuilder.control(''),
    }, {updateOn: 'change'});

    this._overlay.backdropClick()
      .pipe(takeUntil(this._destroy$))
      .subscribe(() => {
        this._overlay.dispose();
      });
  }
Example #9
Source File: router-outlet-settings.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
public static openAsOverlay(config: {anchor: HTMLElement; routerOutlet: SciRouterOutletElement; overlay: Overlay; injector: Injector}): void {
    const {anchor, routerOutlet, overlay, injector} = config;

    const positionStrategy = overlay.position()
      .flexibleConnectedTo(anchor)
      .withFlexibleDimensions(false)
      .withPositions([OVERLAY_POSITION_SOUTH]);

    const overlayConfig = new OverlayConfig({
      panelClass: 'e2e-router-outlet-settings-overlay',
      hasBackdrop: true,
      positionStrategy: positionStrategy,
      scrollStrategy: overlay.scrollStrategies.noop(),
      disposeOnNavigation: true,
      width: 350,
      backdropClass: 'transparent-backdrop',
    });

    const overlayRef = overlay.create(overlayConfig);
    const portal = new ComponentPortal(RouterOutletSettingsComponent, null, Injector.create({
      parent: injector,
      providers: [
        {provide: OverlayRef, useValue: overlayRef},
        {provide: SciRouterOutletElement, useValue: routerOutlet},
      ],
    }));
    overlayRef.attach(portal);
  }
Example #10
Source File: router-outlet-settings.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
constructor(host: ElementRef<HTMLElement>,
              private _routerOutlet: SciRouterOutletElement,
              private _overlay: OverlayRef) {
    this._overlay.backdropClick()
      .pipe(takeUntil(this._destroy$))
      .subscribe(() => {
        this._overlay.dispose();
      });
  }
Example #11
Source File: router-outlet-context.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
public static openAsOverlay(config: {anchor: HTMLElement; routerOutlet: SciRouterOutletElement; overlay: Overlay; injector: Injector}): void {
    const {anchor, routerOutlet, overlay, injector} = config;

    const positionStrategy = overlay.position()
      .flexibleConnectedTo(anchor)
      .withFlexibleDimensions(false)
      .withPositions([OVERLAY_POSITION_SOUTH]);

    const overlayConfig = new OverlayConfig({
      panelClass: 'e2e-router-outlet-context-overlay',
      hasBackdrop: true,
      positionStrategy: positionStrategy,
      scrollStrategy: overlay.scrollStrategies.noop(),
      disposeOnNavigation: true,
      width: 500,
      height: 400,
      backdropClass: 'transparent-backdrop',
    });

    const overlayRef = overlay.create(overlayConfig);
    const portal = new ComponentPortal(RouterOutletContextComponent, null, Injector.create({
      parent: injector,
      providers: [
        {provide: OverlayRef, useValue: overlayRef},
        {provide: SciRouterOutletElement, useValue: routerOutlet},
      ],
    }));
    overlayRef.attach(portal);
  }
Example #12
Source File: loader.interceptor.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 5 votes vote down vote up
private showOverlay(): OverlayRef {
    return this.loaderService.open();
  }
Example #13
Source File: ngx-mat-timepicker.component.ts    From ngx-mat-timepicker with MIT License 5 votes vote down vote up
private _overlayRef: OverlayRef;
Example #14
Source File: modal.service.ts    From sba-angular with MIT License 5 votes vote down vote up
private createOverlay(config: ModalConfig): OverlayRef {
        const overlayConfig = this.getOverlayConfig(config);
        return this.overlay.create(overlayConfig);
    }
Example #15
Source File: modal-ref.ts    From sba-angular with MIT License 5 votes vote down vote up
constructor(private overlayRef: OverlayRef) {
    }
Example #16
Source File: tooltip.directive.ts    From sba-angular with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #17
Source File: image-tooltip.directive.ts    From radiopanel with GNU General Public License v3.0 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #18
Source File: notification.controller.ts    From onchat-web with Apache License 2.0 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #19
Source File: notification.component.ts    From onchat-web with Apache License 2.0 5 votes vote down vote up
/** 浮层 */
  @Input() overlayRef: OverlayRef;
Example #20
Source File: np-tooltip.directive.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #21
Source File: np-time-picker.component.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #22
Source File: np-tags.component.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #23
Source File: np-sidepanel.component.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #24
Source File: loader.service.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #25
Source File: np-popover.directive.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #26
Source File: np-popup-menubar.directive.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #27
Source File: np-dropdown.component.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;
Example #28
Source File: np-dialog-ref.ts    From np-ui-lib with MIT License 5 votes vote down vote up
constructor(
    public overlay: OverlayRef,
    public content: string | TemplateRef<any>,
    public config: NpDialogConfig,
    public data: any
  ) { }
Example #29
Source File: np-date-picker.component.ts    From np-ui-lib with MIT License 5 votes vote down vote up
private overlayRef: OverlayRef;