File

src/tooltip.component.ts

Implements

OnDestroy

Metadata

selector ng-cdk-tooltip
styleUrls tooltip.component.scss
templateUrl ./tooltip.component.html

Index

Properties
Methods
Outputs

Constructor

constructor()

Outputs

ngCdkClosed $event type: EventEmitter

Methods

closeTooltip
closeTooltip()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void

Properties

id
id: String
Type : String
showCloseButton
showCloseButton:
Default value : false
templateRef
templateRef: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ViewChild
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>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""