如何在不使用ngbTooltip的情况下在角度4应用程序中实现bootstrap 4工具提示?

时间:2018-06-18 09:28:39

标签: angular twitter-bootstrap

任何人都可以告诉如何在角度4应用程序中实现bootstrap 4工具提示而不使用Error Message: "status": 404, "message": "A reference was made to a file or folder which does not exist.\r\nclientRequestId: 20e05109-7277-4476-924b-ff69715a9134", "source": "sftp-logic-cp-westeurope.logic-ase-westeurope.p.azurewebsites.net"

ngbTooltip

我正在获取对象并不支持角度4应用程序中的工具提示。我已经包含了bootstrap库

由于

1 个答案:

答案 0 :(得分:0)

您可以创建这样的简单指令:

import { Directive, AfterViewInit, ElementRef } from '@angular/core';
// Here we declare $ as variable to be able to use it after.
declare var $:any;

@Directive({
  selector:'[tooltip]'
})
export class TooltipDirective implements AfterViewInit {

  constructor(private elementRef: ElementRef) {

  }

  ngAfterViewInit() {
    // Wait for Dom Element rendering, then elementRef represent DOM element from where Directive is bootstraped.
    $(this.elementRef.nativeElement).tooltip();
  }
}

然后你可以像这样使用它:

<p tooltip="" data-toggle="tooltip" title="Hooray!">
  Start editing to see some magic happen :)
</p>

Online sample