Solution 1:
Using plugin ['ui-bootstrap'].
You can use below code:
In HTML:
<head>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="https://code.angularjs.org/1.2.9/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="myApp">
<table class="table" ng-controller="ctrl">
<thead>
<tr><th>column</th></tr>
</thead>
<tbody>
<tr>
<td>
<span tooltip="that">this</span>
</td>
</tr>
<tr ng-repeat="foo in bar">
<td><span tooltip="{{foo.tooltip}}">{{foo.content}}</span></td>
</tr>
</tbody>
</table>
</body>
And in script file:
// Code goes here
var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('ctrl', ['$scope', function ($scope) {
$scope.bar = [];
// doing something async (exec time simulated by setTimeout)
myAsyncFunc(function (bar) {
$scope.$apply(function() {
$scope.bar = bar;
});
});
}]);
var myAsyncFunc = function (done) {
// simulate some kind of timeout due to processing of the function
setTimeout(function () {
return done([{tooltip: 'this is the tooltip', content: 'this is the content'}]);
}, 500);
};
here is the link for working plunker Click Here
Solution 2: (Without dependency injection)
Using Directive:
HTML PART:
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://code.angularjs.org/1.2.9/angular.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!-- Latest compiled and minified CSS -->
<script src="script.js"></script>
<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>
Script part:
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!"},
{ name: "item 03", tooltip: "This is item 03 tooltip!"},
{ name: "item 04", tooltip: "This is item 04 tooltip!"},
{ name: "item 05", tooltip: "This is item 05 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"});
}
}
})
Link for Plunker for this solution Plunker
I have applied it on your code. Please see this plunker
As per your requirement, using ng-attr-title find the link of plunker