File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
projects/components/src/tooltip Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,23 @@ import { POPOVER_DATA } from '../popover/popover';
8
8
template : `
9
9
<div class="tooltip-container">
10
10
<ng-container *ngIf="this.isComplexContent; else simpleContent">
11
- <ng-container *ngTemplateOutlet="this.content"> </ng-container>
11
+ <ng-container *ngTemplateOutlet="this.templateRef; context: this.data.context"> </ng-container>
12
12
</ng-container>
13
13
14
14
<ng-template #simpleContent>
15
- {{ this.content }}
15
+ {{ this.data. content }}
16
16
</ng-template>
17
17
</div>
18
18
`
19
19
} )
20
20
export class TooltipContentContainerComponent {
21
21
public readonly isComplexContent : boolean ;
22
- public constructor ( @Inject ( POPOVER_DATA ) public readonly content : string | TemplateRef < unknown > ) {
23
- this . isComplexContent = content instanceof TemplateRef ;
22
+ public readonly templateRef : TemplateRef < unknown > ;
23
+
24
+ public constructor (
25
+ @Inject ( POPOVER_DATA ) public readonly data : { content : string | TemplateRef < unknown > ; context : unknown }
26
+ ) {
27
+ this . isComplexContent = data . content instanceof TemplateRef ;
28
+ this . templateRef = data . content as TemplateRef < unknown > ;
24
29
}
25
30
}
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ export class TooltipDirective implements OnDestroy {
16
16
@Input ( 'htTooltip' )
17
17
public content ?: TemplateRef < unknown > | string | number ;
18
18
19
+ @Input ( 'htTooltipContext' )
20
+ public context ?: unknown ;
21
+
19
22
private readonly mouseEnter$ : Subject < MouseEvent > = new Subject ( ) ;
20
23
private readonly mouseLeave$ : Subject < MouseEvent > = new Subject ( ) ;
21
24
@@ -55,7 +58,7 @@ export class TooltipDirective implements OnDestroy {
55
58
56
59
this . popover = this . popoverService . drawPopover ( {
57
60
componentOrTemplate : TooltipContentContainerComponent ,
58
- data : this . content ,
61
+ data : { content : this . content , context : this . context ?? { } } ,
59
62
position : {
60
63
type : PopoverPositionType . Relative ,
61
64
origin : this . host ,
You can’t perform that action at this time.
0 commit comments