【问题标题】:BootstrapTooltip position on mouse cursor [closed]鼠标光标上的引导工具提示位置[关闭]
【发布时间】:2016-01-29 07:33:53
【问题描述】:

我想要带有鼠标光标的引导工具提示。是否可以在 angularjs 中做到这一点。如果不是,那还有什么替代方法。

【问题讨论】:

  • 问题不清楚,请详细说明
  • 对不起,我想我解释得不好。我需要工具提示随光标移动,而不是用任何锚标签或其他标签修复

标签: javascript angularjs twitter-bootstrap-tooltip


【解决方案1】:

是的,让我用例子来解释一下,如何使用 angularjs + Bootstrap 显示工具提示。

控制器:

var myApp = angular.module("myApp", []);

function MyCtrl($scope) {
    $scope.items = [{ name: "item 01", tooltip: "This is item 01 tooltip!"},
                    { name: "item 02", tooltip: "This is item 02 tooltip!"}];
    console.log("MyCtrl");
}

myApp.directive('tooltip', function () {
    return {
        restrict:'A',
        link: function(scope, element, attrs)
        {
            $(element)
                .attr('title',scope.$eval(attrs.tooltip))
                .tooltip({placement: "right"});
        }
    }
})

HTML:<a> html 标记中使用tooltip 来显示工具提示。

<div ng-app="myApp">
    <div ng-controller="MyCtrl">
        <li ng-repeat="item in items" >
            <a rel="tooltip" tooltip="item.tooltip">{{item.name}}</a>
        </li>
    </div>
</div>

这就完成了。请参阅live example

【讨论】:

  • 对不起,我想我解释得不好。我需要工具提示随光标移动,而不是用任何锚标签或其他标签修复
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多