src/tooltip.component.ts
| selector | ng-cdk-tooltip |
| styleUrls | tooltip.component.scss |
| templateUrl | ./tooltip.component.html |
Properties |
Methods |
Outputs |
constructor()
|
|
Defined in src/tooltip.component.ts:24
|
ngCdkClosed
|
$event type: EventEmitter
|
|
Defined in src/tooltip.component.ts:22
|
|
| closeTooltip |
closeTooltip()
|
|
Defined in src/tooltip.component.ts:33
|
|
Returns :
void
|
| ngOnDestroy |
ngOnDestroy()
|
|
Defined in src/tooltip.component.ts:28
|
|
Returns :
void
|
| id |
id:
|
Type : String
|
|
Defined in src/tooltip.component.ts:20
|
| showCloseButton |
showCloseButton:
|
Default value : false
|
|
Defined in src/tooltip.component.ts:24
|
| templateRef |
templateRef:
|
Type : TemplateRef<any>
|
Decorators : ViewChild
|
|
Defined in src/tooltip.component.ts:18
|
import { Component, EventEmitter, OnDestroy, Output, TemplateRef, ViewChild } from '@angular/core';
import { trigger, state, style, animate, transition } from '@angular/animations';
@Component({
selector: 'ng-cdk-tooltip',
templateUrl: './tooltip.component.html',
styleUrls: ['./tooltip.component.scss'],
animations: [
trigger('state', [
state('initial, void, hidden', style({transform: 'scale(0)'})),
state('visible', style({transform: 'scale(1)'})),
transition('* => visible', animate('150ms cubic-bezier(0.0, 0.0, 0.2, 1)')),
transition('* => hidden', animate('150ms cubic-bezier(0.4, 0.0, 1, 1)')),
])
],
})
export class NgCdkTooltipComponent implements OnDestroy {
@ViewChild(TemplateRef)
templateRef: TemplateRef<any>;
id: String;
@Output('ngCdkClosed')
closed = new EventEmitter<void>();
showCloseButton = false;
constructor() { }
ngOnDestroy() {
this.closed.emit();
this.closed.complete();
}
closeTooltip() {
this.closed.emit();
}
}
<ng-template>
<div [@state]="'visible'" role="tooltip" aria-hidden="false">
<div class="tooltip_content">
<span aria-hidden="true" class="tooltip_close icon_close" (click)="closeTooltip()" *ngIf="showCloseButton">
<svg viewPort="0 0 12 12" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line x1="1" y1="11" x2="11" y2="1" stroke="grey" stroke-width="2" />
<line x1="1" y1="1" x2="11" y2="11" stroke="grey" stroke-width="2" />
</svg>
</span>
<span [id]="id">
<ng-content></ng-content>
</span>
</div>
</div>
</ng-template>