I want bootstrap tooltip with my mouse cursor. Is it possible to do that in angularjs. If not then what will be the alternative of this.
Asked
Active
Viewed 151 times
-1
-
question is not clear.please elaborate – Murali Jan 29 '16 at 07:43
-
1Check this out.. https://angular-ui.github.io/bootstrap/#/tooltip – Moid Jan 29 '16 at 07:43
-
Sorry I think I does not explain it well. I need the tooltip move with the cursor, not fix with any anchor tag or other tag – Pranjal Jan 29 '16 at 08:45
1 Answers
1
Yes, Let me explain it with example that how can you display tooltip with angularjs + Bootstrap.
Controller:
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:
Use tooltip
at <a>
html tag to display 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>
And that's done. Please see live example.

Mr Lister
- 45,515
- 15
- 108
- 150

AddWeb Solution Pvt Ltd
- 21,025
- 5
- 26
- 57
-
Sorry I think I does not explain it well. I need the tooltip move with the cursor, not fix with any anchor tag or other tag – Pranjal Jan 29 '16 at 08:44