beeb
HTML
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://code.angularjs.org/1.2.9/angular.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<body ng-app="myApp">
<table class="table" ng-controller="ctrl">
<thead>
<tr><th>column</th></tr>
</thead>
<tbody>
<tr>
<td>
<span title="that" data-toggle="tooltip">this</span>
</td>
</tr>
<tr ng-repeat="foo in bar" bs-tooltip>
<td ng-bind-html="to_trusted(foo)"></td>
</tr>
</tbody>
</table>
<script>
$(document).ready(function () {
$('.table span').tooltip();
});
</script>
</body>
JavaScript
var app = angular.module('myApp', []);
app.controller('ctrl', ['$scope', '$sce', function ($scope, $sce) {
$scope.bar = [];
// doing something async (exec time simulated by setTimeout)
myAsyncFunc(function (bar) {
$scope.bar = bar;
$scope.$apply(); // needed because of the timeout in the function
});
$scope.to_trusted = function (html_code) {
return $sce.trustAsHtml(html_code);
};
}]);
app.directive('bsTooltip', function () {
return function (scope, element, attrs) {
// trying to register the new tooltips
element.find('span').tooltip();
};
});
var myAsyncFunc = function (done) {
// simulate some kind of timeout due to processing of the function
setTimeout(function () {
return done(['<span title="bar" data-toggle="tooltip">foo</span>', '<span title="I don\'t work" data-toggle="tooltip">moo</span>']);
}, 500);
};