I am trying to write a directive in angular2 + typescript, which makes the tooltip show only with active ellipsis (show full text only pops up when it is not fully displayed and ends with "..."), I found this answer in stackoverflow:
show tooltip only with active ellipsis
Now I am trying to translate this jQuery function:
In typescript. so far this is what i got:
import { Directive, ElementRef } from '@angular/core';
@Directive({ selector: '[isEllipsisActive]' })
export class IsEllipsisActiveDirective {
constructor(el: ElementRef) {
if (el.nativeElement.classList.contains('className')) {
if (this.isEllipsisActive(el.nativeElement)) {
}
}
}
isEllipsisActive(e: any) {
return (e.offsetWidth < e.scrollWidth);
}
}
I cannot figure out how to get text from an element and pass it to the element title using typescript. any ideas?
Thank!
source
share