Use Tippy.js in Angular

前端 未结 2 882
别那么骄傲
别那么骄傲 2021-01-19 16:26

I have a directive with the following code

import { Directive, Input, OnInit, ElementRef, SimpleChanges, OnChanges } from \'@angular/core\';
import tippy fr         


        
2条回答
  •  不思量自难忘°
    2021-01-19 16:58

    I'm not sure what they were trying to accomplish in the linked repo you have included. To get tippy.js to work though, you should be able to change the directive to the following:

    import { Directive, Input, OnInit, ElementRef } from '@angular/core';
    import tippy from 'tippy.js';
    
    @Directive({
      /* tslint:disable-next-line */
      selector: '[tippy]'
    })
    export class TippyDirective implements OnInit {
    
      @Input('tippyOptions') public tippyOptions: Object;
    
      constructor(private el: ElementRef) {
        this.el = el;
      }
    
      public ngOnInit() {
        tippy(this.el.nativeElement, this.tippyOptions || {}, true);
      }
    }
    

    Working example repo

提交回复
热议问题