Skip to content

Commit

Permalink
feat: base tooltip support override TooltipComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtianze committed Dec 23, 2020
1 parent 7baac16 commit b4f383f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tooltip/base-tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';
import { ComponentPortal, ComponentType } from '@angular/cdk/portal';
import {
AfterViewInit,
ChangeDetectorRef,
Expand Down Expand Up @@ -104,6 +104,7 @@ export class BaseTooltip<T = any>
hide = new EventEmitter<void>();

protected overlayRef: OverlayRef;
protected componentClass: ComponentType<any> = TooltipComponent;
protected componentIns: TooltipComponent;
protected hostHovered = false;
protected tooltipHovered = false;
Expand Down Expand Up @@ -150,7 +151,10 @@ export class BaseTooltip<T = any>
return;
}
this.overlayRef = this.createOverlay();
const portal = new ComponentPortal(TooltipComponent, this.viewContainerRef);
const portal = new ComponentPortal(
this.componentClass,
this.viewContainerRef,
);
this.componentIns = this.overlayRef.attach(portal).instance;
this.componentIns.setupInputs({
inputClass$: this.inputClass$$.asObservable(),
Expand Down

0 comments on commit b4f383f

Please sign in to comment.