### File

`projects/commons/src/lib/elements/tooltip/directives/tooltip.directive.ts`

### Implements

`OnInit`

### Metadata

Selector | `[clsTooltip]`

### Index

###### Methods
Public ngOnInit
###### Inputs
clsTooltip

### Constructor

`constructor(element: ElementRef, renderer: Renderer2)`
Defined in projects/commons/src/lib/elements/tooltip/directives/tooltip.directive.ts:10
Parameters :
Name | Type | Optional
element | `ElementRef` | No
renderer | `Renderer2` | No

### Inputs

clsTooltip
Type : `ITooltip`
Defined in projects/commons/src/lib/elements/tooltip/directives/tooltip.directive.ts:10

### Methods

Public ngOnInit
`ngOnInit()`
Defined in projects/commons/src/lib/elements/tooltip/directives/tooltip.directive.ts:17
Returns : `void`

    import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core';

    import { ITooltip } from '../interfaces';

    @Directive({
        selector: '[clsTooltip]',
    })

    export class TooltipDirective implements OnInit {
        @Input('clsTooltip') private options: ITooltip;

        constructor(
            private readonly element: ElementRef,
            private readonly renderer: Renderer2,
        ) {}

        public ngOnInit(): void {
            const color = `is-tooltip-${ this.options.color && this.options.color.split('-').pop() }`;

            this.element.nativeElement.classList
                .add(color, 'tooltip', `is-tooltip-${ this.options.position }`);

            this.renderer.setAttribute(this.element.nativeElement, 'data-tooltip', this.options.label);

            if (this.options.isMultiLine) {
                this.element.nativeElement.classList.add('is-tooltip-multiline');
            }

            if (this.options.isActive) {
                this.element.nativeElement.classList.add('is-tooltip-active');
            }
        }
    }

# result-matching ""

# No results matching ""