清单项目的工具提示

时间:2018-12-02 12:56:28

标签: html font-awesome-5

<li class="list-inline-item">
   <i class="fab fa-mailchimp"></i>
</li>

我要添加此字体真棒图标。我需要一个工具提示以在悬停时显示一些文本。做这个的最好方式是什么?

谢谢。

1 个答案:

答案 0 :(得分:1)

timerSubs: Subscription;  // to cancel existing timer   
ngOnInit() {
    this.calculateTimeForTimer()
}

calculateTimeForTimer() {
    let expirationDate = new Date();
    expirationDate.setTime(expirationDate.getTime() + 10 * 1000); // 10 seconds from now.
    // in your case use your own duration/date of expiration
    let alertDate = new Date(expirationDate);
    alertDate.setTime(alertDate.getTime() - 5 * 1000); // 5 seconds before expiration
    // in your case subtract 5 minutes instead of 5 seconds
    let timeDuration = (expirationDate.getTime() - alertDate.getTime());
    this._startTimer(timeDuration);
}

private _startTimer(timeDuration) {
    if (this.timerSubs) {
        this.timerSubs.unsubscribe();
    }

    this.timerSubs = timer(timeDuration).subscribe((data) => {
      // make the API call, and then calculate appropriate duartion and call startTimer() again
      of("This is your new Token").pipe(delay(2000)).subscribe((apiData) => {
          console.log("Data from API", apiData);
          this.calculateTimeForTimer();
      })
    })
}